DOC PREVIEW
UCSD CSE 120 - Processes

This preview shows page 1-2-3-4-5-6 out of 18 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 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 18 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 18 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 18 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 18 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 18 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CSE 120CSE 120Principles of Operating Principles of Operating SystemsSystemsSystemsSystemsWinter 2007Winter 2007Lecture 3: ProcessesLecture 3: ProcessesKeith Marzullo and Geoffrey M. VoelkerKeith Marzullo and Geoffrey M. VoelkerProcessesProcessesz This lecture starts a class segment that covers processes, threads, and synchronizationprocesses, 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.z Today’s topics are processes and process management What are the units of execution?How are those units of execution represented in the OS?January 16, 2007 CSE 120 – Lecture 3 – Processes 2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?2The ProcessThe Processz The process is the OS abstraction for executionIt is the unit of executionIt is the unit of execution It is the unit of scheduling It is the dynamic execution context of a programz A process is sometimes called a job or a task or a sequential processz A sequential process is a program in executionIt defines the sequential instructionatatime execution of aJanuary 16, 2007 CSE 120 – Lecture 3 – Processes 3It defines the sequential, instruction-at-a-time execution of a program Programs are static entities with the potential for executionProcess ComponentsProcess Componentsz A process contains all of the state for a program in executionexecution 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 valuesJanuary 16, 2007 CSE 120 – Lecture 3 – Processes 4 A set of operating system resources» Open files, network connections, etc.z A process is named using its process ID (PID)3Process Address SpaceProcess Address SpaceStack0xFFFFFFFFStatic DataHeap(Dynamic Memory Alloc)AddressSpaceSPJanuary 16, 2007 CSE 120 – Lecture 3 – Processes 50x00000000Code(Text Segment)Static Data(Data Segment)PCProcess StateProcess Statez A process has an execution state that indicates what it is currently doingyg 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)January 16, 2007 CSE 120 – Lecture 3 – Processes 6»It cannot make progress until event is signaled (disk completes)z 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?4Process State GraphProcess State GraphCreate ProcessNew ReadyWaitingProcessI/O DoneSchedule ProcessUnschedule ProcessJanuary 16, 2007 CSE 120 – Lecture 3 – Processes 7RunningTerminatedProcess ExitI/O, Page Fault, etc.Process Data StructuresProcess Data StructuresHow does the OS represent a process in the kernel?zAt any time there are many processes in the systemzAt any time, there are many processes in the system, each in its particular statez The OS data structure representing each process is called the Process Control Block (PCB)z The PCB contains all of the info about a processz The PCB also is where the OS keeps all of a process’ January 16, 2007 CSE 120 – Lecture 3 – Processes 8hardware 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 hardware5PCB Data StructurePCB Data Structurez The PCB contains a huge amount of information in one large structureone large structure» Process ID (PID)» Execution state» Hardware state: PC, SP, regs» Memory management» Scheduling» Accounting»Pointers for state queuesJanuary 16, 2007 CSE 120 – Lecture 3 – Processes 9»Pointers for state queues» Etc.z It is a heavyweight abstractionstruct proc (Solaris)struct 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.*/*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 *p_pgidp; /* process group ID info *//**/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 *//** Fields protected by p_lock*/kcondvar_t p_cv; /* proc struct's condition variable */kcondvar_t p_flag_cv;kcondvar_t p_lwpexit; /* waiting for some lwp to exit */kcondvar_t p_holdlwps; /* process is waiting for its lwps *//* to to be held. */ushort_t p_pad1; /* unused */uint_t p_flag; /* protected while set. *//* flags defined below */clock_t p_utime; /* user time, this process */clock_t p_stime; /* system time, this process */clock_t p_cutime; /* sum of children's user time */clock_t p_cstime; /* sum of children's system time */caddr_t *p_segacct; /* segment accounting


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

Threads

Threads

29 pages

Security

Security

16 pages

Paging

Paging

13 pages

Processes

Processes

32 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?