Setting the interrupt priority in 4.3BSD and SVR4 Synchronization - UNIX is re-entrant
- UNIX is non-preemptive, keeping the kernel states consistent.
- Relinquish CPU voluntarily.
- Blocks the process (make it sleep).
- Lock: a single bit flag
- wanted(flag):
- sleep():
- wake(): wake all the waiting processes.
- upon waking up: check once again to make sure.
Algorithm for resource locking Blocking Interrupts - Blocking interrupts while accessing critical sections.
- Critical region:few & brief.
- Blocked interrupts may access the critical region.
- Different interrupts may have the same ipl
- Blocking an interrupt may block others.
UNIX Process Implementation - fork:
- creates a new process.
- returns 0 to the child, PID to the parent
- exec:
Using fork & exec - if ((result = fork()==0){
- /* child code*/
- … …
- if (execve(“new program”),…)<0)
- perror(“execve failed!”);
- } else if (result<0) {
- perror(“fork”);/*fork failed*/
- }
- /*parent continures here*/
Shell creating a process - A highly simplified shell
The ls Command Process Creation - Almost an exact clone of the parent.
- Reserve swap space for the child
- Allocate a new PID and proc structure for the child
- Initialize proc structure
- Allocate address translation map (ATM)
- Allocate u area and copy
- Update the u area to refer to the new ATM & Swap space
- Add the child to the set of processes sharing the text region of the program
- Duplicate the parent’s data and stack regions update ATM to refer to these new pages.
- Acquire references to shared resources inherited by the child
- Initialize the hardware context
- Make the child runnable and put it on a scheduler queue
- Arrange to return with 0
- Return the PID to the parent
Do'stlaringiz bilan baham: |