Unix foundations


Setting the interrupt priority in 4.3BSD and SVR4


Download 1.51 Mb.
bet7/9
Sana18.06.2023
Hajmi1.51 Mb.
#1583315
1   2   3   4   5   6   7   8   9
Bog'liq
process

Setting the interrupt priority in 4.3BSD and SVR4

Interrupt handling

Synchronization

  • UNIX is re-entrant
  • UNIX is non-preemptive, keeping the kernel states consistent.
  • Relinquish CPU voluntarily.

Blocking Operations

  • 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

New Processes & Programs

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

Download 1.51 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling