diff --git a/.logs/fnames_log.txt b/.logs/fnames_log.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Hardware/Memory/Basics.md b/Hardware/Memory/Basics.md index 96cf2e2..37cdd66 100644 --- a/Hardware/Memory/Basics.md +++ b/Hardware/Memory/Basics.md @@ -8,4 +8,4 @@ tags: In essence the main memory is just a large storage area for a bunch of binary digits. Each slot for a 0 or 1 is called a bit: -> This is where the running kernal and processes reside - they're just big collections of bits. A CPU is just an operator on memory. It reads its instructions and data from the memory and write back out to the memory. \ No newline at end of file +> This is where the running kernal and processes reside - they're just big collections of bits. A CPU is just an operator on memory. It reads its instructions and data from the memory and write back out to the memory. (_How Linux Works: Third Edition_, Brian Ward 2021) \ No newline at end of file diff --git a/Operating Systems/Basic Model.md b/Operating Systems/Basic Model.md index de97e95..e28a34f 100644 --- a/Operating Systems/Basic Model.md +++ b/Operating Systems/Basic Model.md @@ -1,6 +1,6 @@ --- tags: - - os + - Operating_Systems - Linux --- @@ -10,13 +10,14 @@ We can abstract the Linux OS into three operational levels or tiers, from the bo
User processes
-
The running programs that the kernel manages. Also known as the user space. Comprising
+
The running programs that the kernel manages. Also known as the user space. Comprising:
Kernel
+
The core of the operating system. Software residing in memory that tells the CPU where to look for its next task. Acts as a mediator and primary interface between the hardware and the user processes. Comprising:
+ +!! Add info on kernel mode and user mode +https://www.geeksforgeeks.org/user-mode-and-kernel-mode-switching/ \ No newline at end of file diff --git a/Operating Systems/The Kernel.md b/Operating Systems/The Kernel.md index e69de29..5164118 100644 --- a/Operating Systems/The Kernel.md +++ b/Operating Systems/The Kernel.md @@ -0,0 +1,32 @@ +--- +tags: + - Operating_Systems + - Linux +--- + +# The Kernel + +The kernel acts as the primary mediator between the hardware (CPU, memory) and user processes. Let's look at each of its responsibilities in greater depth: +* process management +* memory management +* device drivers +* system calls + +## Process management + +> A process is just another name for a running program. Process management is the starting, pausing, resuming, scheduling and terminating of processes. + +On modern computers it appears that multiple processes can run simultaneously at once. This is only because the processor is so fast that we do not detect changes. In fact access to the CPU is always sequential. The sequence in which multiple programs are allowed to access the CPU is managed by the kernel. + +> Consider a system with a one-core CPU. Many processes may be _able_ to use the CPU, but only one process can actually use the CPU at any given time..Each process uses the CPU for a fraction of a second, then pauses, then another process uses it for a fraction of a second and so on... (_How Linux Works: Third Edition_, Brian Ward 2021) + +This process of the CPU shuffling between multiple processes is called _context switching_. + +The role of the kernel in facilitating this, is as follows: +1. CPU runs process for a time slice based on its internal time. Then hands control back to the kernel (kernel mode) +2. Kernel records current state of CPU and memory. This is necessary in order to resume the progress that was just interupted. +3. The kernel executes any tasks that arose in the last timeslice executed by the CPU (e.g. collecting data from I/0) +4. Kernel then analyses the list of processes that are ready to run next and chooses one. +5. Kernel prepares memory for this new process and prepares the CPU. +6. Kernel tells CPU how long the time slice for the new process will last. +7. Kernel switches the CPU into user mode and hands control of CPU to the process.