[FreeBSD] Kernel Organization

2024. 7. 9. 19:06ComputerScience/FreeBSD

 

 

 

3.1 Kernel Organization

  • The FreeBSD kernel can be viewed as a service provider to user processes. Processes usually access these services through system calls. Some services, such as process scheduling and memory management, are implemented as processes that execute in kernel mode or as routines that execute periodically within the kernel.
  • In this chapter, we describe how kernel services are provided to user processes, and we explain some of the ancillary processing done by the kernel. Then we describe the basic kernel services provided by FreeBSD and provide details of their implementation.

 

 

 

System Processes

  • All FreeBSD user-level processes originate from a single process that is crafted by the kernel at startup. Table 3.1 lists the most important of the processes that are created immediately and exist always. They are kernel processes, and they function wholly within the kernel.
  • Kernel processes execute code that is compiled into the kernel’s load image and operate with the kernel’s privileged execution mode. Often these processes have many threads. For example, the intr process starts a kernel thread for each device to handle interrupts for that device.
  • After creating the kernel processes, the kernel creates the first process to execute a program in user mode; it serves as the parent process for all subsequent processes. The first user-mode process is the init process—historically, process 1. This process does administrative tasks, such as spawning getty processes for each terminal on a machine, collecting exit status from orphaned processes, (운체 시간에 배웠던 내용.!) and handling the orderly shutdown of a system from multiuser to single-user operation. The init process is a user-mode process, running outside the kernel. (커널 밖 user mode에서 가장 머저 실행되는 프로세스) 

 

 

 

Permanent kernel processes.

 

 

 

System Entry

Entrances into the kernel can be categorized according to the event or action that initiates them:

• Hardware interrupt

• Hardware trap

• Software-initiated trap 

 

  • Hardware interrupts arise from external events, such as an I/O device needing attention or a clock reporting the passage of time. (For example, the kernel depends on the presence of a real-time clock or interval timer to maintain the current time of day, to drive process scheduling, and to initiate the execution of system timeout functions.) Hardware interrupts occur asynchronously and may not relate to the context of the currently executing process. 
  • Hardware traps may be either synchronous or asynchronous but are related to the current executing process. Examples of hardware traps are those generated as a result of an illegal arithmetic operation, such as dividing by zero. (0으로 나누기) 
  • Software-initiated traps are used by the system to force the scheduling of an event, such as process rescheduling or network processing, as soon as possible. Software-initiated traps are implemented by setting a flag that is checked whenever a process is preparing to exit from the kernel. If the flag is set, the software-interrupt code runs instead of exiting from the kernel.
    • System calls are a special case of a software-initiated trap - the machine instruction used to initiate a system call typically causes a hardware trap that is handled specially by the kernel.

 

 

 

https://ystc1247.tistory.com/entry/Interrupt-Trap-Fault

 

 

 

https://tk-one.github.io/2019/07/09/os-computer-architecture/