03-processes-threads - Processes and Threads Prof. Sirer CS...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Processes and Threads Prof. Sirer CS 4410 Cornell University
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is a program? A program is a file containing executable code (machine instructions) and data (information manipulated by these instructions) that together describe a computation Resides on disk Obtained through compilation and linking
Background image of page 2
Preparing a Program Source files compiler/ assembler Object files Linker PROGRAM An executable file in a standard format, such as ELF on Linux, Microsoft PE on Windows Header Code Initialized data BSS Symbol table Line numbers Ext. refs static libraries (libc)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Running a program Every OS provides a “loader” that is capable of converting a given program into an executing instance, a process ± A program in execution is called a process The loader: ± reads and interprets the executable file ± Allocates memory for the new process and sets process’s memory ± pushes “argc”, “argv”, “envp” on the stack ± sets the CPU registers properly & jumps to the entry point
Background image of page 4
Process != Program Header Code Initialized data BSS Symbol table Line numbers Ext. refs Code Initialized data BSS Heap Stack DLL’s mapped segments Executable Process address space Program is passive Code + data Process is running program stack, regs, program counter Example: We both run IE: - Same program - Separate processes
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Process Management Process management deals with several issues: ± what are the units of execution ± how are those units of execution represented in the OS ± how is work scheduled in the CPU ± what are possible execution states, and how does the system move from one to another
Background image of page 6
7 The Process A process is the basic unit of execution ± it’s the unit of scheduling ± it’s the dynamic (active) execution context (as opposed to a program, which is static) A process is sometimes called a job or a task or a sequential process. A sequential process is a program in execution; it defines the sequential, instruction-at-a-time execution of a program.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 What’s in a Process? A process consists of at least: ± the code for the running program ± the data for the running program ± an execution stack tracing the state of procedure calls made ± the Program Counter, indicating the next instruction ± a set of general-purpose registers with current values ± a set of operating system resources (open files, connections to other programs, etc.) The process contains all the state for a program in execution.
Background image of page 8
9 Process State There may be several processes running the same program (e.g. multiple web browsers), but each is a distinct process with its own representation. Each process has an execution state that indicates what it is currently doing, e.g.,: ± ready: waiting to be assigned to the CPU ± running: executing instructions on the CPU ± waiting: waiting for an event, e.g., I/O completion As a program executes, it moves from state to state
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Process State Transitions New Ready Exit clock interrupt descheduling dispatch
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 35

03-processes-threads - Processes and Threads Prof. Sirer CS...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online