Program - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Program

Description:

... Threads ... Each thread has it's own PC, registers, stack, and state... just ... Benefits of using Threads. Ability of multithreaded entities to share address ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 17
Provided by: derek94
Category:
Tags: program | threads

less

Transcript and Presenter's Notes

Title: Program


1
Program
  • Whats a program?
  • Is a static entity. Only exist as an idea, on
    paper, or as a file.

2
Processes
  • Process An abstraction of a running program.
  • Multiprogramming allows for the processor to
    switch between several different programs.
  • Processor may only run each program a fraction of
    a second

3
Pseudoparallelism
  • Processor switches between each program so fast
    it gives the appearance of programs running in
    parallel.
  • This is in contrast to true parallelism which
    requires a system with more than 1 CPU.

4
Thinking in Parallel
  • Very hard for humans to do
  • We have a conceptual model called the sequential
    process or just process.
  • Associated with a process are its code, input,
    output and state.

5
Consider 3 processes
  • How do we maintain where each process is in its
    execution as each one is switched out of running
    on the CPU?
  • Each process has a logical PC that is saved with
    the process
  • So, when a particular process is going to execute
    on the CPU what happens with the logical PC?
  • Loaded into the Physical PC

6
Four Events that can trigger process creation
  • System Initialization
  • Execution of a process creation system call by a
    running process
  • A user request to create a new process.
  • Initiation of a batch process.
  • HW Using the Plus reference manual, what is the
    name of the function to create a process (task)?

7
Types of Processes
  • Foreground
  • Processes that interact with the user and perform
    work for them
  • Background
  • Not associated with a user, but perform some type
    of specific function for the system (accepting
    incoming email)

8
After a process has performed its job
  • It is terminated by the following methods
  • Normal exit (voluntary)
  • Error exit (voluntary)
  • Fatal error (involuntary)
  • Killed by another process (involuntary)
  • HW What is the function that terminates a
    Nucleus Process (task)? Can a Nucleus task
    execute again after it is terminated? What
    functions must be called to do this?

9
Process States
  • Running A process that is executing on a CPU.
    If the system has n CPUs, at most n processes may
    be in the running state.
  • Ready A process that is not allocated to the
    CPU but is ready to run. A ready process could
    execute if allocated to a CPU.

10
Process States (cont.)
  • Blocked A process that is waiting for some
    event to occur before it can continue executing.
    This event is often the completion of an I/O
    operation.
  • Do not confuse Blocked and Ready Processes

11
Process State (cont)
  • Terminated process that has halted its
    execution but a record of the process is still
    maintained by the OS. This record may be useful
    to other processes.

12
Process State Diagram
Terminated
Exit
Running
Scheduler decides another process should run
Process blocks waiting for some external event
Scheduler decides a process should run
Blocked
Ready
Once a process is created It is placed in the
ready state
Process is unblocked once external event occurs
New
13
So, how do we keep track of information about a
process?
  • Process Control Block (PCB) Just an array of
    structures with 1 entry per process
  • A PCB entry contains the PC, SP, memory
    allocation, status of its open files, scheduling
    info, anything to restore the process when
    switching states
  • Nucleus Plus uses a PCBs but calls them another
    name
  • Page 80 in the book has a more complete list of
    fields often found in a PCB

14
Processes vs. Threads
  • Each process has its own address space
    containing program text and data along with other
    resources.
  • A process also has a thread of execution, so
    threads are a part of a particular process.
  • Each thread has its own PC, registers, stack,
    and state just like a process

15
Processes vs. Threads (cont.)
  • But threads allow us to use the same
  • Address space
  • Global Variables
  • Open Files
  • Obviously we do not want to create separate
    processes (more overhead) if these resources can
    be shared.

16
Benefits of using Threads
  • Ability of multithreaded entities to share
    address space and data.
  • Easier to create and destroy in comparison to
    processes which have resources.
  • Improved Performance when substantial computing
    power is available
  • Useful for multiprocessor systems
Write a Comment
User Comments (0)
About PowerShow.com