Fundamental Concepts, Chapter 2
- You should read chapters 1 and 2.
- The Kernel
- Frequently in /boot
- vm -virtual memory
- linu - linux
- z - compressed
- version information
- The boot loader, based on /boot/grub.conf
- Accesses this file system
- Uncompresses the kernel
- Loads it into memory
- Jumps to the starting address of the kernel
- He lists things a kernel does
- Process scheduling
- A process is a program that has been loaded for execution.
- Ready to run
- Running
- Waiting for a resource
- Suspended
- What is Multitasking?
- What does preemptive mean?
- Linux is preemptive multitasking
- A quantum is the maximum length of time a process is allowed to run without interruption.
- But it may be interrupted sooner if it needs resources.
- Memory Management
- File System
- Linux/Unix treats everything as a file.
- EVERYTHING
- Process creation, maintenance and termination
- Device access
- Linux treats everything as a file.
- Networking
- Linux treats everything as a file.
- Most CPS have two modes
- Normal mode, where most commands are executed
- Kernel/Supervisor mode where protected commands are executed
- IE: halt, interacting with devices
- Generally access to supervisor mode is through a system call
- The kernel uses this mode to protect processes from each other and to protect the system from harmful actions by users.
- A process' life
- The process is spawned (or forked) and it begins executing
- It really has no knowledge of where it is
- all references to memory and hard drive are through the kernel
- It has no, or very little knowledge of other processes
- Unless an interprocess communication mechanism is used.
- At some point it will do one of the following
- Exit and the story is over
- Make a system call or use up it's quanta or have an extraordinary event
- In this case, it makes a system call of some form
- And the kernel begins to execute code on behalf of the process
- At the end of the kernel code, the scheduler is called
- And then the kernel code returns, but perhaps not to the same process.
-
- The big thing is as a process working with other processes, has no knowledge of
- Where it will be interrupted (will it execute the next instruction or not?)
- What process executes next.
- MUCH more detail is provided in section 3.1 for those detail hungry people.
- Processes
- Are created with a system call fork
- where a parent process creates a child process.
- The child is mostly identical to the parent
- A process can call exec to run a different program.
- Eventually the process will call exit to exit.
- Each process is provided with memory
- Text, data, heap, stack, ... as we discuss in architecture.
- Each process has a unique process id
- Processes have credentials (the id of the user that owns the process, plus other ids it might assume)
- More information is stored too.
- There is a special process called init or systemd
- The change from init to systemd is new (last 5 years)
- A decent article.
- This is a daemon process, or a process that
- Is running in the background, disassociated from a terminal
- Is most likely performing some task on behalf of the kernel
- Runs long term (look at ps on mirkwood)
- This process is the first started and normally has pid 1
- And parent id (ppid) 0.
- It has some special tasks
- It is responsible for spawning and respawing most other daemons
- It ultimately becomes the parent of orphan processes.
- It usually can not be killed
- If this happens, the system normally shuts down.
- It generally doesn't receive signals, unless it wants them.
- It usually runs as root.
- Non-processes or kernel-threads
- Programs that show up with commands as [cmd] from ps are kernel threads.
- These are processes started directly by the kernel
- Or the kernel thread daemon (kthreadd)
- They are an equivalent to a daemon
- You probably can't kill, stop, suspend, or do anything else to them.
- And you probably don't want to.
- ps
- This is a unix/linux command
- It shows a snapshot of the current processes
- ps -ef to see all processes
- ps -ef | more to really see all processes
- ps -ef | grep pts/15 to see all processes associated with pseudo terminal 15
- There are many, many command line arguments, see man ps
- ps -ef --forest is cool
- top
- top is an interactive display of processes
- man top.