Process Control Blocks Linux PCBS: Operating Systems Operating Systems 2
Process Control Blocks Linux PCBS: Operating Systems Operating Systems 2
Linux PCBs
PCBs
Where the OS can find all the information it needs to know
about a process.
memory
open streams/files
devices, including abstract ones like windows
links to condition handlers (signals)
processor registers (single thread)
process identification
process state - including waiting information
priority
owner
which processor
links to other processes (parent, children)
process group
resource limits/usage
access rights
process result - may be waited for by another process
Doesn't have to be kept together
Different information is required at different times
UNIX for example has two separate places in memory with
this information. One of them is in the kernel the other is
in user space. Windows does the same.
Operating Systems
Operating Systems
Lecture 06
page
Lecture 06
page
Windows NT PCBs
Operating Systems
Lecture 06
page
Operating Systems
Lecture 06
page
NT PCB (cont.)
Lecture 06
A collection of PCBs
Commonly an array of pointers to PCBs
Operating Systems
Process Table
page
Operating Systems
Process states
Lecture 06
page
Being created
Operating Systems
Lecture 06
page
Operating Systems
Lecture 06
page
fork
Whichever way
find a spare (or create a new) PCB (what if there isn't
one?)
mark it "being created"
generate a unique identifier
get some memory (what if there isn't any?) or
at least fill in the page table entries
set up PCB fields with initial values
set priority, resource limits
when all set up change the state to "runnable"
this could be done by inserting into a queue of
runnable processes
Operating Systems
Lecture 06
page
Operating Systems
Lecture 06
Test
page 10
exec
checks to see if the file is executable
i = 0
while i < 2:
os.fork()
os.system('ps -o pid,ppid,comm,stat')
i += 1
(os.fork() == 0)
os.execl("nextprog", ...)
Operating Systems
Lecture 06
page 11
Operating Systems
Lecture 06
page 12
Two solutions
NT process creation
1. copy on write
No copy is made at first.
The data pages of the parent process are set to read only.
If a write occurs the resulting exception makes a copy of the
page for the other process both copies are then marked
writable.
1. vfork
Trust the programmers to know what they are doing.
Operating Systems
Lecture 06
page 13
Operating Systems
Lecture 06
page 15
Operating Systems
Lecture 06
page 14