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)
What gets copied when you use a fork() command?
The file descriptor table. Thus, the parent and child point to eh same entry in the system file table.
What does the term Exec refer to?
A family of functions where each of the functions replace a process’s program (the one calling one of the exec functions) with a new loaded program.
A call to a function from exec loads what type of file into memory?
A binary file.
What happens to the original the original memory image of the programming calling the exec function?
It destroys the memory image image of the program calling it.
Referring to the exec function family: Functions with “p” in their name do what? ex. execvp, execlp
Search for the program in the path indicated by the PATH environment variable; functions without p must be given full path
Referring to the exec function family: Functions with “v” in their name do what? ex. exec, execvp, execve
They differ from functions with l (execl, execlp, execle) in the way arguments are passed.
Referring to the exec function family: Functions with “e” in their name do what?
Functions with “e” accept array of environment variables.
True or false: The child return to the old program if exec succeeds.
False! Child will not retune to the old program unless exec fails. This is an important point to remember.
True or false: File descriptors are not preserved when a child calls an exec onto itself.
False, file descriptors ARE preserved.