6 - Processes Flashcards
What is multiprogramming?
OS gives CPU to
another program if current program
must wait on I/O
What is Cooperative Multitasking?
Programs can
voluntarily yield CPU to another program
What is Preemptive Multitasking?
A program gets a fraction of a second to execute, then OS automatically switches to the next program, and so on Almost all modern OSes implement this
What is Multithreading?
allows even more efficient
multitasking, usually preemptive
What is Multitasking?
Concurrent execution of multiple programs
Usually an illusion of parallelism
Can run more processes than there are CPUs
What is the use of Multitasking?
Allows us to reduce CPU idling during I/O
What is a process?
An abstraction of a program in execution.
Is a program the same thing as a process?
NO!
Program is PASSIVE
Process is active
Does a process get its own address space? What is in this address space?
• text section: the program code
• data section: global variables, constant
variables
• heap: memory for dynamic allocation during run time
• stack: temporary data (parameters, return address, local variables)
What is the Process Control Block (PCB)?
A data structure comprising of bits of information needed by the OS for process management.
What are the typical parts of the PCB?
HIGH LEVEL
- Process/Memory/File Management
• process state
• program counter, CPU registers
• priority, pointers to various queues
• memory management info: eg. page tables, segment
tables, etc.
• accounting info: eg. CPU time, timeout values, process
numbers, etc.
• I/O status info: open files, I/O devices, etc.
What is a Process Table?
A collection of all PCBs
Which system call does UNIX define to create a new process?
fork()
What is a Parent Process?
The process that is creating a new process
What is a Child Process?
A newly created process
What is a PID?
A unique process identifier - Each process gets one
Which system call does UNIX define to terminate a process?
exit() or kill()
How do you start an external program in UNIX?
First fork() to create a new process, then start external program with exec()
What does a PID of 0 mean?
The process is the child process.
What does a PID < 0 mean?
An error occurred.
What is the difference between the system() and popen() C functions?
system() just uses fork() to create a child process that executes the command
popen() opens a pipe between the parent and child (The parent has control over the child’s input and output streams).
What is the difference the UNIX and Windows process organization?
UNIX - Parent and child processes continue to be associated, forming a process hierarchy
Windows - All processes are equal, the parent process can give the control of its children to any other process.
What is the init or systemd process?
The first process started after booting?
What is the PID of init?
Always 1
What is an orphaned process? Which process adopts orphaned processes?
Parent terminates before child
init
Which of the following executes in kernel mode? • A user program • A library function call • A system call • A system call wrapper function
A system call
In C, printf() is a system call.
• True
• False
False
When 4 programs are executing on a computer with a single CPU, how many program counters are there?
4 - One for each process
When does a program become a process?
When it is executed
What is the name of the PCB data structure in Linux?
Process Control Block
What is CPU utilization?
Probability that at least one of the processes is not waiting on I/O
What is the function to create a new process in Windows?
CreateProcess()
Why would a process want to create a new process?
• System initialization (boot)
- background processes - daemons, services
• Application decides to spawn additional processes
- eg. to execute external programs or to do parallel work
• A user requests to create a new process
- eg. launching an application from desktop
• Starting a batch job
- mainframes
What us a daemon?
A computer program that runs as a background process, rather than being under the direct control of an interactive user.
Does each process have its own address space?
YES
What are the different methods for allocating resources for a new process?
Directly from OS
A subset of parents resources
Parent shares resources
Hybrids
What options does a parent have after they spawn a new child process?
Wait until the child is finished
Continue to operate concurrently
Operate concurrently and synchronize with child