week 2 Flashcards
pseudoparallelism
used to describe the effect that a CPU has by switching between different processes in a short amount of time to make it seem like multiple processes are all running at once
multiprocessor system
system with two or more CPU’s sharing the same physical memory
process
an instance of an executing program including the current values of the program counter, registers and variables
multiprogramming
rapid switching back and forth of programs
program counter
- each process will have an individual logical program counter, this is loaded into the physical program counter when the process begins to run and saved when the process is finished (for the time being)
process computation time
rate at which a process computes is never the same therefore processes must not be programmed with assumptions about timing
difference between process and program
- a process is an activity with a program, input, output and a state
- a program is a set of instructions stored on disk
four principal events causing a process to be created
1) System initialisation
2) Execution of a process-creation system call by a running process
3) User request to create a new process
4) Initiation of a batch job
- only relevant to batch systems on large mainframes
-
daemon
a background process that is not associated with a particular user
foreground process
processes that interact with users and perform work for them
UNIX fork() system call
creates an exact clone of the calling process
parent process makes a call to the child process
parent and child processes have the same memory image, environment strings, open files
parent and child have distinct address spaces
child process does not start from the beginning, but from where the parent process called child
four conditions resulting in process termination
1) normal exit (voluntary)
2) error exit (voluntary)
3) fatal error (involuntary)
4) killed by another process (involuntary)
three process states
1) running - using CPU
2) ready - runnable, temporarily stopped to let another process run
3) blocked - unable to run until some external event occurs
process state transitions
running - blocked: process blocks for input
running - ready: scheduler picks another process
ready - running: scheduler picks process
blocked - ready: input becomes available
a process can not go from blocked to running or from ready to blocked
PCB
process control block
- entry in a process table
- contains information about process state, program counter, stack pointer, memory allocation, status of files, scheduling info
interrupt vector
location at the bottom of memory containing the address of the interrupt service procedure
interrupt:
- saves registers in process table for current entry
- stack pointer set to point to a temporary stack
(done in assembly language)
do processes share the same address space?
do threads?
processes: no
threads: yes
finite state machine
each computation has a saved state, specific set of events that can change the state
three ways to construct a server
1) threads - blocking calls, parallelism
2) single threaded process - blocking calls, no parallelism
3) finite state machine - nonblocking system calls, parallelism, interrupts
multithreading
having multiple threads in the same process
threads have their own
program counter: keeps track of which instruction to execute next
registers: hold current working variables
stack: contains execution history
state
race condition
when two or more processes are attempting to read or write to some shared data at the same time, leading to unexpected results
mutual exclusion (in the context of running two processes)
while one process is editing a file, another process is excluded from also editing the file to reduce race conditions
critical region of a program
region where shared memory is accessed