Chapter 6, Processes
- Please read chapter 6.
- I intend to cover this chapter lightly.
- The loader
- Historically a loader was a process that
- Reads the contents of an executable file.
- Places it into memory in the appropriate location.
- Copy command line arguments to the correct location in the stack.
- Initialize registers
- Jump to the entry point
- At one time this was a process that the operator had to run
- This is integrated into the os through the exec family of system/library calls.
- fork creates a new process
- exec loads an executable into memory and begins execution.
- Binary file formats
- There have been a number of binary file formats
- a.out format : original unix, assembler output
- coeff: Common object file format
- elf: executable and linking format, the current standard
- file /bin/ls
- This file contains
- Machine language instructions for the program
- The address where the program starts executing (the address of main)
- The data used by the program (global variables and constants)
- Symbol and relocation tables.
- Shared Library and dynamic linking information
- Once the loader reads the program from the file and has the OS jump to the entry point, the program becomes a process.
- As we have discussed, each process has a unique ID.
- The kernel keeps track of the last pid issued
- When a new process is started, it searches for the next available pid
- The max value is cat /proc/sys/kernel/pid_max
- Changing the value in this file will increase the number of pid (hence processes) available.
- 215 or 32,768 is the max on 32 bit systems.
- 222 or 4,194,304 is the max on 64 bit systems.
- This is linux specific
- Recycling of pids starts at 300 to avoid searching seldom unused lower numbers.
- remember init == systemd for the purpose of most of this discussion.
- pstree is a system command that will show (some) of the system processes and their relationship to each other.