1 - Shell (Part 1) Flashcards
What does information on a process include:
1) Process Stack: includes temporary data (function parameters, return addresses and local variables)
2) Data Selection: Includes global variables
3) Heap: Memory that is dynamically allocated during process run-time
What are the 4 states a process can have:
1) New
2) Running
3) Waiting
4) Terminated
How is a process represented in the operating system?
A process control block.
What information does a process control block include?
Information related to program execution including:
- PID
- state
- program counter
- CPU registers
- CPU-scheduling information
- Memory-management information
- I/O Status Information
Examples of operating system services from user-perspective:
1) User interface (CLI or GUI)
2) Program execution
3) I/O Operations
4) File-system manipulation
What is the command interpreter?
A program that accepts commands from the user and interprets the commands (type of user interface).
What is a system call?
Allows a command to request a service from the operation system.
When a command is executed, what carries out the execution?
A separate process from the shell process - a child process will execute the command.
What does the fork() command do?
Creates a child process that is a duplicate of the parent.
What are the properties of a child process created by fork()?
- Child inherits state from parent process (same program instructions, variables have the same value)
- Parent and child have separate copies of that state
- Child has the same open file descriptors from the parent (might be from 2208)
Switching between the parent and child depends on many factors such as:
- machine load
- system process scheduling
How many processes are created by 4 consecutive fork commands?
Draw out process tree.
Does this code produce a tree or a chain?
pid_t childpid = 0;
for (i=1;i
Tree.
Does this code produce a tree or a chain?
pid_t childpid = 0;
for (i=1;i 0)
break;
Chain of child processes.
How many times does a fork() command return and what does it return?
A fork system call returns twice: 1) returns a zero to the child. 2) returns the child process ID (PID) to the parent)