multiprogramming
play

Multiprogramming Single $PC Multiple $PCs (CPUs point of view) - PDF document

9/10/2018 Multiprogramming Single $PC Multiple $PCs (CPUs point of view) (process point of view) A CSC 452: Scheduling B D A C B C B Dr. Jonathan Misurda D jmisurda@cs.arizona.edu http://www.u.arizona.edu/~jmisurda D C B A


  1. 9/10/2018 Multiprogramming Single $PC Multiple $PCs (CPU’s point of view) (process point of view) A CSC 452: Scheduling B D A C B C B Dr. Jonathan Misurda D jmisurda@cs.arizona.edu http://www.u.arizona.edu/~jmisurda D C B A Time Life Cycle of a Process Created Process Ready A running program and its associated data Blocked Running (waiting) Exit Process Table Process Table Entry Process management File management Processes Registers Root directory May be Program counter Working (current) directory stored CPU status word File descriptors on stack … Stack pointer User ID 0 1 N -2 N -1 Process state Group ID Priority / scheduling parameters Process ID Scheduler Parent process ID Signals Memory management Process start time Pointers to text, data, stack Total CPU usage or Pointer to page table 1

  2. 9/10/2018 Processes and Threads Process 1 Process 2 Process 3 Process 1 Thread User A stream of instructions and their space associated state Threads Threads System Kernel Kernel space Thread State Threading Thread 1 Thread 2 Thread 3 Per process items User space Address space Open files Child processes Process Signals & handlers Thread 1’s Accounting info stack Global variables Thread 3’s stack Per thread items Per thread items Per thread items Thread 2’s Program counter Program counter Program counter stack Registers Registers Registers Stack & stack pointer Stack & stack pointer Stack & stack pointer Kernel State State State Multithreading in Action Multithreaded Webserver Webserver while(TRUE) { When in the Course of human We hold these truths to be self- destructive of these ends, it is the process events, it becomes necessary for evident, that all men are created Right of the People to alter or to one people to dissolve the political equal, that they are endowed by their abolish it, and to institute new getNextRequest(&buf); bands which have connected them Creator with certain unalienable Government, laying its foundation on with another, and to assume among Rights, that among these are Life, such principles and organizing its the powers of the earth, the Liberty and the pursuit of Happiness.-- powers in such form, as to them shall handoffWork(&buf); separate and equal station to which That to secure these rights, seem most likely to effect their Safety Governments are instituted among and Happiness. Prudence, indeed, will Worker the Laws of Nature and of Nature's Men, deriving their just powers from dictate that Governments long God entitle them, a decent respect the consent of the governed, --That established should not be changed for } to the opinions of mankind requires whenever any Form of Government light and transient causes; and thread that they should declare the causes which impel them to the separation. becomes accordingly all while(TRUE) { waitForWork(&buf); lookForPageInCache(&buf,&page); if(pageNotInCache(&page)) { Kernel Kernel readPageFromDisk(&buf,&page); } Web page returnPage(&page); cache Network } connection 2

  3. 9/10/2018 User Threads vs. Kernel Threads Process Thread Kernel Kernel Process Threading Thread Process Thread state library state state state 3

Recommend


More recommend