OS Implementing Processes, Threads, and Resources - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

OS Implementing Processes, Threads, and Resources

Description:

The Abstract Machine Interface Cont. ... trap is user mode instruction ... List of related processes(parent/child/sibling) List of child processes. Address space ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 24
Provided by: cstlcs
Category:

less

Transcript and Presenter's Notes

Title: OS Implementing Processes, Threads, and Resources


1
OS Implementing Processes, Threads, and
Resources
2
Implementing the Process Abstraction
OS interface
OS Address Space
CPU
ALU
Machine Executable Memory
Control Unit

3
Modern Processes and Threads

Pi CPU


OS interface
4
Classic Processes Vs. Modern Processes
  • Classic process may contain a base thread,
    multiprogramming is thru space-multiplexing
    processes doing time-multiplexing jobs
  • Modern process each one contains multiple
    threads
  • User space thread POSIX threads library, outside
    of OS
  • Kernel thread Windows supports, within OS
  • An OS that supports kernel threads
    time-multiplexing the execution of threads
    instead of processes

5
The Address Space
Executable Memory
-- A collection of addresses(bytes) that a thread
can reference
Address Space
Address Binding
Process
6
Building the Address Space
  • Some parts are built into the environment
  • Files
  • System services
  • Some parts are imported at runtime
  • Mailboxes
  • Network connections
  • Memory addresses are created at compile (and run)
    time

7
Process Manager Responsibilities
  • Process creation and termination
  • Thread creation and termination
  • Process/thread synchronization
  • Resource allocation
  • Resource protection
  • Cooperation with the device manager to implement
    I/O
  • Implementaion of the address space

8
Hardware Process
-- a name to represent the iterative activity of
the control unit, as it fetches and executes
instructions
Machine is Powered up
Bootstap
Process Manager
Interrupt Handler
P1
P,2
Pn
Loader

Hardware process progress
9
The Abstract Machine Interface
Application Program
Abstract Machine Instructions
User Mode Instructions
User Mode Instructions
10
The Abstract Machine Interface Cont.
  • Defined by the set of instructions that the
    hardware can execute when the processor is in
    user mode
  • trap is user mode instruction
  • When program needs execution of a privileged
    instruction, trap switch CPU to supervisor mode
    and branch to an OS function entry point
  • Abstract Machine instruction set, see table 6.1
  • LINUX system calls, see table 6.2

11
Context Switch
  • Process/thread Context refers to the status of
    the processor hardware whenever that particular
    process/thread is being executed
  • Context switch the action taken by the hardware
    process when it suspends execution on one program
    and begins execution on another
  • Context switch can occur when a process/thread
    makes a system call or device interrupts occur

12
Context Switching
Executable Memory
Process Manager
Interrupt Handler
P1
P2
Pn
13
Process Descriptors
  • Also called task structure/process control
    block/task control block
  • Data structure for OS to create/manage processes
  • Information included
  • Internal process name(like an integer)
  • State(base thread current state)
  • owner
  • Thread(reference to a list of threads associated
    with process)
  • List of related processes(parent/child/sibling)
  • List of child processes
  • Address space
  • Resources(a reference to a list of resources held
    by the process
  • Etc.

14
Creating a Process in UNIX
pid fork()
UNIX kernel
Process Table

Process Descriptor
15
Simple State Diagram
Request
Done
Running
Schedule
Request
Start
Allocate
Ready
Blocked
16
UNIX State Transition Diagram
Request
Wait by parent
Done
Running
Schedule
zombie
Other res Request
Ptrace()
I/O Request
Sleeping
Start
Allocate
Runnable
I/O Complete
Resume
Traced or Stopped
Uninterruptible Sleep
17
Resources
Resource Anything that a process can request,
then be blocked because that thing is not
available.
R Rj 0 ? j lt m resource types C cj ? 0
? Rj?R (0 ? j lt m) units of Rj available
Reusable resource After a unit of the resource
has been allocated, it must ultimately be
released back to the system. E.g., CPU, primary
memory, disk space, The maximum value for cj is
the number of units of that resource
Consumable resource There is no need to release
a resource after it has been acquired. E.g., a
message, input data, Notice that cj is
unbounded.
18
Using the Model
  • There is a resource manager, Mgr(Rj) for every Rj

Mgr(Rj)
Process
19
A Generic Resource Manager
Resource Manager
Blocked Processes
Policy
request()
Process
release()
Resource Pool
20
Process Hierarchies
  • Parent-child relationship may be significant
    parent controls childrens execution

Request
Done
Running
Yield
Suspend
Schedule
Request
Start
Suspend
Ready-Active
Activate
Ready-Suspended
Allocate
Allocate
Suspend
Blocked-Active
Blocked-Suspended
Activate
21
Process Manager Overview
Program
Process
Abstract Computing Environment
Deadlock
Process Description
File Manager
Protection
Synchronization
Memory Manager
Device Manager
CPU
Other H/W
Memory
Devices
22
UNIX Organization
Process
Libraries
Process
Process
System Call Interface
Deadlock
Process Description
File Manager
Protection
Synchronization
Memory Manager
Device Manager
Monolithic Kernel
CPU
Other H/W
Memory
Devices
23
Windows NT Organization
Process
Process
T
T
Process
T
T
T
T
Libraries
T
T
T
Subsystem
Subsystem
Subsystem
User
I/O Subsystem
NT Executive
NT Kernel
Hardware Abstraction Layer
Processor(s)
Main Memory
Devices
Write a Comment
User Comments (0)
About PowerShow.com