Process Concept - PowerPoint PPT Presentation

About This Presentation
Title:

Process Concept

Description:

Information associated with each process. Process state. Program counter. CPU register values ... Job queue set of all PCBs in the system. ... – PowerPoint PPT presentation

Number of Views:12
Avg rating:3.0/5.0
Slides: 20
Provided by: marily295
Learn more at: https://www.cs.miami.edu
Category:

less

Transcript and Presenter's Notes

Title: Process Concept


1
Process Concept
  • An operating system executes a variety of
    programs
  • Batch system jobs
  • Time-shared systems user programs or tasks
  • Process a program in execution
  • A process includes
  • Text segment
  • Data segment
  • Stack segment
  • Program counter

2
Process State
  • As a process executes, it changes state
  • new The process is being created.
  • running Instructions are being executed on the
    CPU.
  • waiting The process is waiting for some event
    to occur.
  • ready The process is waiting for the CPU.
  • terminated The process has finished execution.

3
Process Control Block (PCB)
  • Information associated with each process.
  • Process state
  • Program counter
  • CPU register values
  • CPU scheduling information
  • Memory-management information
  • Accounting information
  • I/O status information

4
Process Queues
  • Job queue set of all PCBs in the system.
  • Ready queue set of all processes residing in
    main memory, ready and waiting to execute.
  • Device queues set of processes waiting for a
    resource, e.g., an I/O device.
  • PCBs migrate between the various queues.

5
Ready Queue And Various I/O Device Queues
6
Context Switch
  • When the CPU switches to another process, the
    system must
  • Switch to kernel mode
  • Save the state of the old process
  • Deal with the interrupt
  • Load the saved state for the new process.
  • Hardware (and possibly OS) saves the state of the
    old process
  • The scheduler selects the new process
  • The dispatcher loads the new process
  • Set the PC
  • Switch to user mode
  • Context-switch time is overhead the system does
    no useful work while switching
  • Time dependent on hardware support.

7
CPU Switch From Process to Process
8
Process Creation
  • Parent process create children processes, which,
    in turn create other processes, forming a tree of
    processes.
  • Address space (one of)
  • Child duplicate of parent.
  • Child has a program loaded into it.
  • Execution (one of)
  • Parent and child execute concurrently
  • Parent waits until child terminates
  • Resource sharing (one of)
  • Parent and children share all resources.
  • Children share subset of parents resources.
  • Parent and child share no resources.

9
Process Termination
  • Process executes last statement and tells the OS
  • Output status from child to parent
  • Process resources are (eventually) deallocated
    by the operating system
  • Parent may terminate execution of children
    processes
  • Child has exceeded allocated resources.
  • Task assigned to child is no longer required.
  • Parent is exiting
  • With cascading termination, the operating system
    does not allow child to continue if its parent
    terminates

10
UNIX PCBs
11
UNIX Shell
12
Threads
  • A thread (or lightweight process) is a basic unit
    of CPU utilization it consists of
  • Program counter
  • Register set
  • Stack space
  • A thread shares with its peer threads its
  • Code segment
  • Data segment
  • Operating-system resources
  • A traditional or heavyweight process is equal to
    a task with one thread.

13
Single and Multithreaded Processes
14
Thread Implementations
  • User-level threads library
  • POSIX Pthreads
  • Mach C-threads
  • Solaris threads
  • Kernel Threads
  • Windows 95/98/NT/2000
  • Solaris
  • Linux

15
Many-to-One
  • Many user-level threads mapped to single kernel
    thread.
  • Used on systems that do not support kernel
    threads.

16
One-to-One
  • Each user-level thread maps to kernel thread.
  • Examples
  • Windows 95/98/NT/2000
  • OS/2
  • LinuxThreads

17
Many-to-Many Model
  • Allows many user level threads to be mapped to
    many kernel threads.
  • Allows the operating system to create a
    sufficient number of kernel threads.
  • Solaris 2
  • Windows NT/2000 with the ThreadFiber package

18
Pthreads
  • A POSIX standard (IEEE 1003.1c) API for thread
    creation and synchronization.
  • API specifies behavior of the thread library,
    implementation is up to development of the
    library.
  • Common in UNIX operating systems.

19
Benefits
  • Responsiveness
  • In a multiple threaded task, while one thread is
    blocked and waiting, a second thread in the same
    task can run.
  • Kernel level threads provide a mechanism that
    allows sequential processes to make blocking
    system calls while also achieving parallelism.
  • Resource Sharing
  • Economy
  • Utilization of MP Architectures
Write a Comment
User Comments (0)
About PowerShow.com