Structure of Processes - PowerPoint PPT Presentation

About This Presentation
Title:

Structure of Processes

Description:

Title: Memory Management Author: Steve Armstrong Last modified by: pondyuni Created Date: 11/25/2000 7:18:14 PM Document presentation format: On-screen Show (4:3) – PowerPoint PPT presentation

Number of Views:163
Avg rating:3.0/5.0
Slides: 24
Provided by: Steve1550
Category:

less

Transcript and Presenter's Notes

Title: Structure of Processes


1
Structure of Processes
  • Chapter 6

Process State and Transition Data Structure for
Process Layout of System Memory
THE DESIGN OF THE UNIX OPERATING SYSTEM
Maurice J. bach Prentice Hall
2
Process image in virtural memory
3
Process Creation
  • Assign a unique pid to the new process.
  • Allocate space for all the elements of the
    process image. How much?
  • The process control block is initialized. Inherit
    info from parent.
  • The appropriate linkages are set for scheduling,
    state queues..
  • Create and initialize other data structures

4
Process interruption
  • Two kinds of process interruptions interrupt and
    trap.
  • Interrupt Caused by some event external to and
    asynchronous to the currently running process,
    such as completion of IO.
  • Trap Error or exception condition generated
    within the currently running process. Ex illegal
    access to a file, arithmetic exception.
  • Supervisor call explicit interruption

5
Unix System V
  • All user processes in the system have as root
    ancestor a process called init. When a new
    interactive user logs onto the system,
    initcreates a user process, subsequently this
    user process can create child processes and so
    on. init is created at the boot-time.
  • Process states User running , kernel running,
    Ready in memory, sleeping in memory (blocked),
    Ready swapped (ready-suspended), sleeping swapped
    (blocked-suspended), created (new), zombie ,
    preempted (used in real-time scheduling).

6
Cont.
  • Similar to our 7 state model
  • 2 running states User and Kernel
  • ??transitions to other states (blocked,
    ready) must come from kernel running
  • Sleeping states (in memory, or swapped)
    correspond to our blocking states
  • A preempted state is distinguished from the ready
    state (but they form 1 queue)
  • Preemption can occur only when a process is about
    to move from kernel to user mode

7
Process States and Transitions
exit
8
Data Structures for Process
9
Data Structure for Process (contd.)
per process region table
Kernel region table
u area
main memory
Kernel process table
10
State of a Process
  • Process table entry
  • Contains general fields of processes that must be
    always be accessible to the kernel
  • U area
  • further characteristics of the process only need
    to be accessible to the running process itself

11
Process table entry
  • State field user running, kernel running etc.
  • Fields that allow the kernel to locate the
    process and u area. Requires while context switch
  • Process size kernel know how much space to
    allocate for the process.
  • User ID
  • Process ID

12
Process table entry (contd.)
  • Event descriptor.
  • Used when the process is in the "sleep" state.
  • Scheduling parameters.
  • Allow the kernel to determine the order in which
    processes move to the states "kernel running" and
    "user running
  • A signal field.
  • keeps the signals sent to a process but not yet
    handled.
  • Various timers process execution time, resource
    utilization etc.

13
U Area
  • A pointer to the process table entry
  • User IDs
  • various Timer
  • Execution time in user mode
  • Execution Time in kernel mode
  • An error field keeps error during system call
  • Return value field result of system call

14
U Area (contd.)
  • I/O parameters
  • Amount of data transfer
  • Address of source and target etc.
  • The current directory and current root
  • User file descriptor table
  • Limit fields
  • Restrict process size
  • Restrict size of the file it can write
  • The control terminal field
  • login terminal associated with the process, if
    one exists
  • An array indicates how the process wishes to
    react to signal

15
Per Process Region Table (Pregion)
  • Each pregion entry points to the kernel region
    table
  • Starting virtual (absolute) address of the region
  • Permission filed
  • read-only, read-write, read-execute

16
Kernel Region table
  • Kernel region table contains the pointer to the
    page table which keeps the physical memory address

17
Regions
18
Pages and Page Tables
Logical Page Number Physical Page
Number 0 177 1 54 2 209 3 17
19
Pages and Page Tables (contd.)
20
Process and Context Switching
  • Clock interrupt The OS determines if the time
    slice of the currently running process is over,
    then switches it to Ready state, and dispatches
    another from Ready queue. Process switch
  • Memory fault (Page fault) A page fault occurs
    when the requested program page is not in the
    main memory. OS (page fault handler) brings in
    the page requested, resumes faulted process.
  • IO Interrupt OS determines what IO action
    occurred and takes appropriate action.

21
Cont
  • Process switch A transition between two
    memory-resident processes in a multiprogramming
    environment.
  • Context switch Changing context from a executing
    program to an Interrupt Service Routine (ISR).
    Part of the context that will be modified by the
    ISR needs to be saved. This required context is
    saved and restored by hardware as specified by
    the ISR.

22
The context of a process
  • The context of the process consists of the
    contents of its (user) address space and the
    contents of hardware register and kernel data
    structure that relate to the process.
  • User-level context
  • ??Process Text (ie code read-only)
  • ??Process Data
  • ??User Stack (calls/returns in user mode)
  • ??Shared memory (for IPC)
  • Register level context
  • Program counter,Processor status register,Stack
    pointer, General purpose register

23
  • System-level context
  • ??Process table entry
  • ??the actual entry concerning this process in the
    Process Table maintained by OS
  • ??Process state, UID, PID, priority, event
    awaiting, signals sent, pointers to memory
    holding text, data...
  • ??U (user) area
  • ??additional process info needed by the kernel
    when executing in the context of this process
  • ??effective UID, timers, limit fields, files in
    use .??Kernel stack (calls/returns in kernel
    mode)
  • ??Per Process Region Table (used by memory
    manager).
Write a Comment
User Comments (0)
About PowerShow.com