DOC PREVIEW
UCSD CSE 120 - Processes

This preview shows page 1-2-15-16-31-32 out of 32 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CSE 120 Principles of Operating Systems Spring 2009ProcessesThe ProcessProcess ComponentsProcess Address SpaceProcess StateProcess State GraphProcess Data StructuresPCB Data Structurestruct proc (Solaris)struct proc (Solaris) (2)struct proc (Solaris) (3)PCBs and Hardware StateState QueuesState QueuesPCBs and State QueuesProcess CreationProcess Creation: NTProcess Creation: Unixfork()Example OutputDuplicating Address SpacesDivergenceExample ContinuedWhy fork()?Process Creation: Unix (2)Process Creation: Unix (3)Process Terminationwait() a second…Unix ShellsProcess SummaryNext time…Slide Number 33Context Switch in NachosContext Switch in NachosContext Switch in NachosContext Switch in NachosCSE 120Principles of Operating SystemsSpring 2009Lecture 3: ProcessesGeoffrey M. VoelkerApril 7, 2009 CSE 120 – Lecture 3 – Processes 2Processes This lecture starts a class segment that covers processes, threads, and synchronization These topics are perhaps the most important in this class You can rest assured that they will be covered in the exams Today’s topics are processes and process management 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 the possible execution states of a process? How does a process move from one state to another?April 7, 2009 CSE 120 – Lecture 3 – Processes 3The Process The process is the OS abstraction for execution It is the unit of execution It is the unit of scheduling It is the dynamic execution context of a program 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 Programs are static entities with the potential for executionApril 7, 2009 CSE 120 – Lecture 3 – Processes 4Process Components A process contains all of the state for a program in execution An address space The code for the executing program The data for the executing program An execution stack encapsulating the state of procedure calls The program counter (PC) indicating the next instruction A set of general-purpose registers with current values A set of operating system resources» Open files, network connections, etc. A process is named using its process ID (PID)April 7, 2009 CSE 120 – Lecture 3 – Processes 5Process Address SpaceStack0x000000000xFFFFFFFFCode(Text Segment)Static Data(Data Segment)Heap(Dynamic Memory Alloc)AddressSpaceSPPCApril 7, 2009 CSE 120 – Lecture 3 – Processes 6Process State A process has an execution state that indicates what it is currently doing Running: Executing instructions on the CPU» It is the process that has control of the CPU» How many processes can be in the running state simultaneously? Ready: Waiting to be assigned to the CPU» Ready to execute, but another process is executing on the CPU Waiting: Waiting for an event, e.g., I/O completion» It cannot make progress until event is signaled (disk completes) As a process executes, it moves from state to state Unix “ps”: STAT column indicates execution state What state do you think a process is in most of the time? How many processes can a system support?April 7, 2009 CSE 120 – Lecture 3 – Processes 7Process State GraphNew ReadyRunningWaitingTerminatedCreate ProcessProcess ExitI/O, Page Fault, etc.I/O DoneSchedule ProcessUnschedule ProcessApril 7, 2009 CSE 120 – Lecture 3 – Processes 8Process Data StructuresHow does the OS represent a process in the kernel? At any time, there are many processes in the system, each in its particular state The OS data structure representing each process is called the Process Control Block (PCB) The PCB contains all of the info about a process The PCB also is where the OS keeps all of a process’ hardware execution state (PC, SP, regs, etc.) when the process is not running This state is everything that is needed to restore the hardware to the same configuration it was in when the process was switched out of the hardwareApril 7, 2009 CSE 120 – Lecture 3 – Processes 9PCB Data Structure The PCB contains a huge amount of information in one large structure» Process ID (PID)» Execution state» Hardware state: PC, SP, regs» Memory management» Scheduling» Accounting» Pointers for state queues» Etc. It is a heavyweight abstractionApril 7, 2009 CSE 120 – Lecture 3 – Processes 10struct proc (Solaris)/** One structure allocated per active process. It contains all* data needed about the process while the process may be swapped* out. Other per-process data (user.h) is also inside the proc structure.* Lightweight-process data (lwp.h) and the kernel stack may be swapped out.*/typedef struct proc {/** Fields requiring no explicit locking*/struct vnode *p_exec; /* pointer to a.out vnode */struct as *p_as; /* process address space pointer */struct plock *p_lockp; /* ptr to proc struct's mutex lock */kmutex_t p_crlock; /* lock for p_cred */struct cred *p_cred; /* process credentials *//** Fields protected by pidlock*/int p_swapcnt; /* number of swapped out lwps */char p_stat; /* status of process */char p_wcode; /* current wait code */ushort_t p_pidflag; /* flags protected only by pidlock */int p_wdata; /* current wait return value */pid_t p_ppid; /* process id of parent */struct proc *p_link; /* forward link */struct proc *p_parent; /* ptr to parent process */struct proc *p_child; /* ptr to first child process */struct proc *p_sibling; /* ptr to next sibling proc on chain */struct proc *p_psibling; /* ptr to prev sibling proc on chain */struct proc *p_sibling_ns; /* prt to siblings with new state */struct proc *p_child_ns; /* prt to children with new state */struct proc *p_next; /* active chain link next */struct proc *p_prev; /* active chain link prev */struct proc *p_nextofkin; /* gets accounting info at exit */struct proc *p_orphan;struct proc *p_nextorph;*p_pglink; /* process group hash chain link next */struct proc *p_ppglink; /* process group hash chain link prev */struct sess *p_sessp; /* session information */struct pid *p_pidp; /* process ID info */struct pid


View Full Document

UCSD CSE 120 - Processes

Documents in this Course
Threads

Threads

14 pages

Deadlocks

Deadlocks

19 pages

Processes

Processes

14 pages

Paging

Paging

13 pages

Processes

Processes

18 pages

Threads

Threads

29 pages

Security

Security

16 pages

Paging

Paging

13 pages

Lecture 2

Lecture 2

13 pages

Paging

Paging

8 pages

Threads

Threads

14 pages

Paging

Paging

13 pages

Paging

Paging

26 pages

Paging

Paging

13 pages

Lecture

Lecture

13 pages

Processes

Processes

14 pages

Paging

Paging

13 pages

Security

Security

17 pages

Threads

Threads

15 pages

Processes

Processes

34 pages

Structure

Structure

10 pages

Lecture 3

Lecture 3

13 pages

Lecture 1

Lecture 1

28 pages

Threads

Threads

15 pages

Paging

Paging

30 pages

Load more
Download Processes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Processes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Processes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?