Exploring Linux Kernel and Init Program
Complete exercises at:
In a concise presentation:
- Explain the concept of OS kernel. Distinguish it from other programs and relate it to the smallest running system.
- What files in your system represent the Linux kernel?
- What is the purpose of the Linux/Unix “init” program?
- What program is the “init” program on your Linux system?
- Demonstrate running bash directly as PID 1 (e.g., boot with
init=/bin/bash). Observe and record the terminal/job-control behavior. - Explain why running bash directly as PID 1 loses job control (the “cannot set terminal process group” error) and why signals like Ctrl-C do not work.
- Use an LLM to help you understand items 5–6.
- Document the prompts you used.
- Quote the LLM’s responses.
- Evaluate whether they were correct and complete.
- Include at least one case where the LLM was wrong, vague, or needed correction, and how you verified the correct answer.
- Write a minimal init program that correctly launches bash after complete the
system call exercise.
- Open the console (e.g.,
/dev/console). - Create a new session with
setsid(). - Set the controlling terminal with
ioctl(fd, TIOCSCTTY, 0). execbash.- Demonstrate that job control and signal handling now work
(no warning,
Ctrl-Cinterrupts,Ctrl-Z+fgwork). - Consult the manual pages to answer:
man 2 setsid— What doessetsid(2)return, and under what condition does it fail? (Hint: process group leader.)man 1 setsid— How can a shell script use thesetsidutility instead of calling the syscall directly?man 2 ioctl_tty(orman 4 ioctl_tty) — What doesTIOCSCTTYdo? What happens if the terminal is already the controlling terminal of another session?man 4 tty(orman 7 tty) — Explain the concepts of controlling terminal, session, and foreground process group.- Combining the pages: Why must
setsid()be called beforeTIOCSCTTY?
- (Optional)
straceyour own init to observe thesetsidandioctlcalls in action.
- Open the console (e.g.,
- Investigate the Windows equivalent of the kernel + init pairing.
-
The Windows kernel starts a first user-mode process during boot. What is it, and what does it do? (Hint: its name is a four-letter acronym.)
-
Unlike Linux’s single init/PID 1, Windows distributes the “start everything else” role across multiple processes. Identify at least two other processes involved in this handoff and explain their roles.
-
Does Windows have a single process that stays resident forever as PID 1 does on Linux? Explain your answer.
-
Cite your sources (Microsoft documentation, Windows Internals, or reliable technical references). Note any differences you find across Windows versions.
-
- Discuss lessons learned, errors made, and challenges encountered.
Note: The Windows questions are harder than the Linux ones because the architecture differs and the sources are less uniform. You are not expected to have a perfect answer. You are expected to show your research process, cite what you found, and note where sources disagree or where you got stuck.