UNIX Process Management - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

UNIX Process Management

Description:

Dual mode execution protects the OS routines from the user process code. ... Drawback: bad for real time systems. UNIX Ready States ... – PowerPoint PPT presentation

Number of Views:625
Avg rating:3.0/5.0
Slides: 11
Provided by: weis8
Category:

less

Transcript and Presenter's Notes

Title: UNIX Process Management


1
UNIX Process Management
  • Chapter 3 - Section 4

2
System V Execution
  • Most of the OS executes within the context of the
    user process, as in Figure 3.15 (b)
  • Dual mode execution protects the OS routines from
    the user process code.
  • The user process executes in user mode when it
    executes its own code, in kernel mode when it
    executes OS code.

3
UNIX SVR4 Process Management
  • UNIX has two kinds of processes
  • System processes
  • run in kernel mode and perform functions that
    benefit the system as a whole (memory allocation,
    process swapping...)
  • User processes
  • run in user mode when executing user program code
  • run in kernel mode when responding to system
    calls, traps, and interrupts

4
UNIX Process State Diagram
5
UNIX 9-State Model
  • UNIX has two run states user and kernel.
  • The UNIX sleep states (asleep in memory, asleep
    swapped) correspond to our blocked and blocked
    suspended states.
  • The Preempted and Ready states correspond to our
    Ready state
  • Zombie state is similar to the Exit state.

6
UNIX Run States
  • The Kernel Run state is entered whenever there is
    a mode switch from user to kernel mode.
  • Traditional UNIX systems did not preempt
    processes running in kernel mode, in order to
    protect system data structures.
  • Drawback bad for real time systems

7
UNIX Ready States
  • Ready to Run and Preempted states are
    essentially the same.
  • Processes enter the Ready state when they are
    first created or when they unblock.
  • Processes enter the Preempted state when the
    kernel preempts them due to presence of higher
    priority process.

8
UNIX Process Creation
  • fork() is the UNIX system call to create a new
    process. (see p. 148 for steps)
  • The new process (the child) is an exact copy of
    the parent, so there are now two virtually
    identical processes.
  • exec() system call can be used to overlay code
    segment in child with a new program, so parent
    and child are different.

9
UNIX Process Creation
  • When fork() complete, the OS can
  • return control to parent process (usual result)
  • schedule the child process
  • schedule an entirely different process
  • fork() returns 0 to the child, childs pid to the
    parent

10
Creating a New UNIX Process
  • int pid
  • pid fork()
  • if (pid 0) / parent and child return here /
  • / child process executes here /
  • exit(0)
  • else if (pid gt 0)
  • / parent process executes here /
  • wait() / if parent wants to wait for child
    to finish /
  • else / pid lt0 indicates an error /
Write a Comment
User Comments (0)
About PowerShow.com