Process
Main concept in a operating system: is a running program abstraction.
Pseudo parallelism: The CPU is switched between processes, given the illusion of parallelism.
Process Model
All programs, including the operating system, are organized in a sequential process set.
In a concept model, each process has its own CPU.
Multiprogramming is used to switch the CPU between processes.
Attention:
Depending on how the CPU is switched, process execution time vary.
Execution at different moments may results in different execution time.
In UNIX, time considerations for use in real-time applications are not reliable.
Analogy
Computer scientist making a cake.
PROCESS: activities:
Interruptions are possible: son is attacked by bee and run into kitchen.
Process States
Implementation
Device (disc) starts an interruption
Hardware puts on stack:
Program Counter
Program status word
registers
CPU jumps to the specified address to serve the interruption
Attendant service save all register (assembly)
Attendant service runs the service
Attendant service finds which process requested the service
The process state is changed from blocked to ready
The scheduler is called to select next process
The control returns to the attendant service
The registers are reload
The process restarts
A Process Consists of:
Preemptive Multitasking: the OS periodically decides to stop the execution of a process and starts the execution of the another process. Eventually, the stopped process must come back to the execution point where it was when it was interrupted.
All process information must be explicitly stored. Process tables implement this.
Process tables implement this.
A Suspend Process Consists of:
Example:
control goes back to the shell process.
while (TRUE) {
read_command (command, parameters);
if (fork() != 0){
wait (&status);
} else
execve (command, parameters, 0);
} Process can create processes
Other process System Calls:
Memory request
Wait a child process termination
Memory reallocation
Signals
Signals are OS mechanisms to notify events to processes. A signal can suspend, in a temporary way, process execution, save his registers on stacks and start a special program to treat it.
Ex: time out, memory violation, etc.
UID
Each authorized person to use the system has a UID (user identification).
Each started process has the UID from the user that started it.
The super-user has a special UID. This UID can violate the protection rules.
Files
The second bigger set of System Calls works with the FILE SYSTEM.
Main function of the OS: hide particularities from discs and other I/O devices. The programmer must have an abstract model of the file system. This model must be independent of file system devices implementation.
Directory tree is a UNIX key concept, used to group files:
The processes and files hierarchy are both organized in trees. However, they have many differences:
Process hierarchies are not very depth, but file hierarchies are.
Process hierarchies have a short life. File hierarchies can last for years.
Normally, child processes can be accessed or modified only by their parent process, while files can be accessed by anyone.
Each file, in a directory hierarchy, can be specified using its pathname.
A "/" on the beginning of a file pathname indicates that the path is absolute.
On each moment, each process has a working directory, used to find processes' files without absolute pathnames.