02.Processes - OSStructure, Processes&ProcessManagement...

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

View Full Document Right Arrow Icon
1 OS Structure, Processes & Process Management
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 What is a Process? A process is a program during execution. Program = static file (image) Process = executing program = program + execution state. A process is the basic unit of execution in an operating system Each process has a number, its process identifier (pid). Different processes may run different instances of the same program E.g., my javac and your javac process both run the Java compiler At a minimum, process execution requires following resources: Memory to contain the program code and data A set of CPU registers to support execution
Background image of page 2
3 Program to Process We write a program in e.g., Java. A compiler turns that program into an instruction list. The CPU interprets the instruction list (which is more a graph of basic blocks). void X (int b) { if(b == 1) { int main() { int a = 2; X(a); }
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Process in Memory Program to process. void X (int b) { if(b == 1) { int main() { int a = 2; X(a); } What you wrote What is in memory. void X (int b) { if(b == 1) { int main() { int a = 2; X(a); } Code main; a = 2 X; b = 2 Heap Stack What must the OS track for a process?
Background image of page 4
5 Processes and Process Management Details for running a program A program consists of code and data On running a program, the loader: reads and interprets the executable file sets up the process’s memory to contain the code & data from executable pushes “argc”, “argv” on the stack sets the CPU registers properly & calls “_start()” Program starts running at _start() _start(args) { initialize_java(); ret = main(args); exit(ret) } we say “process” is now running, and no longer think of “program” When main() returns, OS calls “exit()” which destroys the process and returns all resources
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 Keeping track of a process A process has code. OS must track program counter (code location). A process has a stack. OS must track stack pointer. OS stores state of processes’ computation in a process control block (PCB). E.g., each process has an identifier (process identifier, or PID) Data (program instructions, stack & heap) resides in memory, metadata is in PCB (which is a kernel data structure in memory)
Background image of page 6
7 Process Life Cycle Processes are always either executing , waiting to execute or blocked waiting for an event to occur Running Running Ready Ready Blocked Blocked Start Start Done Done A preemptive scheduler will force a transition from running to ready.   A non-preemptive scheduler waits.
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 Process Contexts Example: Multiprogramming Operating System Operating System “System Software” “System Software” User Program 1 User Program 1 User Program 2 User Program 2 User Program n
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 27

02.Processes - OSStructure, Processes&ProcessManagement...

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

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