Lecture 2 - Computer Science And Engineering

2y ago
16 Views
2 Downloads
1.95 MB
14 Pages
Last View : 21d ago
Last Download : 2m ago
Upload by : Bennett Almond
Transcription

CSCE 351Operating System KernelsProcesses, Context Switchesand InterruptsSteve Goddardgoddard@cse.unl.eduhttp://www.cse.unl.edu/ goddard/Courses/CSCE3511Processes The basic agent of work, the basic building blockProcess characterization» Program code» Processor/Memory state» Execution state The state transition diagramReadyRunningWaiting2

Process Actions Create and DeleteSuspend and ResumeProcess synchronizationProcess communication3Multiprogramming4

Physical v. Logical ConcurrencyWhy is logical concurrency useful? Structuring of computation Performanceprocess Pbegin:Read(var):end Psystem call Read()beginStartIO(input device)WaitIO(interrupt)EndIO(input device):end Read» Single process I/O5Physical v. Logical ConcurrencyPerformance considerations Multithreaded I/Oprocess Pbegin:StartRead() compute Read(var):end Psystem call StartRead()beginRequestIO(input device)end StartReadsystem process Read()beginloopWaitForRequest()System Read(var)WaitForRequestor():end loopend Readsystem call Read()beginSignalReader(input device)end Read6

Process Creation Paradigms COBEGIN/COEND FORK/JOIN Explicit processcreationcobeginS1 S2 :Sncoendbegin:fork(foo):join(foo):endprocedure foo()begin::end foobegin:P:endprocess Pbegin::end P7Threads 3 processes» Each with one thread 1 process» Three threads8

Process SchedulingImplementing and managing state transitionsReadyRunningHeadTailWaitingready queueHeaddevice/conditionqueuesTailnamenamenamemem ptrsmem ptrsmem ptrsreg valuesreg valuesreg values.Headnext ptrnext ptrprev ptrprev ptr.next ptrprev ptrTail9Why Schedule?Scheduling goals Example: two processes execute concurrentlyprocess P1beginfor i : 1 to 5 do read a char process a char end forend P1 process P2begin execute for 1 sec end P2Performance without schedulingP1P21 100200300400500 600700800900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000Performance with schedulingP1P21100200300400500 600700800900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 200010

Types of Schedulers Long term schedulers» adjust the level of multiprogramming throughadmission control Medium term schedulers» adjust the level of multiprogramming by suspendingprocesses Short term schedulers» determine which process should execute next11Short Term SchedulingWhen to scheduleReadyRunningHeadTailWaitingready queueHeadTaildevice/conditionqueuesWhen a process makes a transition.1. from running to waiting2. from running to ready3. from waiting to ready(3a. a process is created)4. from running to terminated12

Short Term SchedulingHow to schedule — Implementing a context switchReadyRunningHeadTailWaitingready queueHeaddevice/conditionqueuesTailcontext switch(queue : system queue)var next : process idbeginDISABLE INTSinsert queue(queue, runningProcess)next : remove queue(readyQueue)dispatch(next)ENABLE INTSend context switchdispatch(proc : process id)begin save memory image of runningProcess save processor state of runningProcess load memory image of proc load processor state of proc runningProcess : procend dispatch13Implementing a Context SwitchDispatching Case 1: ()main()“P1”“P2: running”P2’s dispatch:dispatch()begin save state of P2 load state of P1 :end dispatch14

Implementing a Context SwitchDispatching Case 1: ait()startIO()deposit()read()main()main()“P1: running”“P2”P1’s dispatch:dispatch()begin save state of P1 load state of P2 :end dispatch15Implementing a Context SwitchDispatching Case 1: 1’s dispatch:dispatch()begin save state of P1 load state of P2 :end dispatch“P2 : running”P2’s dispatch:dispatch()begin:RunningProcess: P2end dispatch16

Implementing a Context SwitchDispatching Case 1: IO()deposit()read()main()main()“P1”“P2: running”context switch(queue : system queue)var next : process idbeginDISABLE INTSinsert queue(queue, runningProcess)next : remove queue(readyQueue)dispatch(next)ENABLE INTSend context switch17Implementing a Context SwitchDispatching Case 1: sit()read()main()main()“P1”“P2 : running”18

Implementing a Context SwitchDispatching Case 1: d()main()main()“P1”“P2 : running”19Implementing a Context SwitchDispatching Case 1: main()“P1”“P2 : running”20

Implementing a Context SwitchDispatching Case 2: ain()“P1”“P2: running”P2’s dispatch:dispatch()begin save state of P2 load state of P1 :end dispatch21Implementing a Context SwitchDispatching Case 2: rInt()timerInt()foo()bar()main()main()“P1: running”“P2”P1’s dispatch:dispatch()begin save state of P1 load state of P2 :end dispatch22

Implementing a Context SwitchDispatching Case 2: �s dispatch:“P2 : running”P2’s dispatch:dispatch()begin save state of P1 load state of P2 :end dispatchdispatch()begin:RunningProcess: P2end dispatch23Implementing a Context SwitchDispatching Case 2: in()main()“P1”“P2 : running”24

Interrupts Device sends a signal to an interrupt controllerController interrupts the CPU via the INT pin25Kernel response to anInterrupt - sketch CPU stacks PC and other key registersCPU loads new PC from interrupt vector tableAssembly language procedure saves registersAssembly language procedure sets up INT stackC ISR runs (usually reads and buffers input)Scheduler marks any newly ready tasksScheduler decides which process will run nextC procedure returns to the assembly codeAssembly language procedure switches to newcurrent process26

Response to an Interrupt details for Intel processors Controller interrupts the CPU via the INT pinCPU disables interrupts and pushes PC and other key registers onto thecurrent process stackCPU signals the controller via INTA (interrupt acknowledge) signal toput interrupt number on the system data busCPU reads the system data bus and uses that value as an index into theinterrupt vector table to find the pointer of the interrupt handler, whichis an assembly routine wrapper for the ISR (i.e., an indirect jump)The interrupt handler fills out the stack frame with general registers,switches to an interrupt stack and calls the C ISRWhen the ISR completes, the handler switches to a process stackframe, pops the general registers, and executes the iretd (return frominterrupt) instruction to pop the remaining instructions in the stackframe to restore the system state27Interrupts vs System CallsInterruptSystem Call28

2. from running to ready 3. from waiting to ready (3a. a process is created) 4. from running to terminated Ready Running Waiting Head Tail ready queue Head Tail device/condition queues. 13 Short Term Scheduling How to schedule — Implement

Related Documents:

Introduction of Chemical Reaction Engineering Introduction about Chemical Engineering 0:31:15 0:31:09. Lecture 14 Lecture 15 Lecture 16 Lecture 17 Lecture 18 Lecture 19 Lecture 20 Lecture 21 Lecture 22 Lecture 23 Lecture 24 Lecture 25 Lecture 26 Lecture 27 Lecture 28 Lecture

Lecture 1: A Beginner's Guide Lecture 2: Introduction to Programming Lecture 3: Introduction to C, structure of C programming Lecture 4: Elements of C Lecture 5: Variables, Statements, Expressions Lecture 6: Input-Output in C Lecture 7: Formatted Input-Output Lecture 8: Operators Lecture 9: Operators continued

Lecture 1: Introduction and Orientation. Lecture 2: Overview of Electronic Materials . Lecture 3: Free electron Fermi gas . Lecture 4: Energy bands . Lecture 5: Carrier Concentration in Semiconductors . Lecture 6: Shallow dopants and Deep -level traps . Lecture 7: Silicon Materials . Lecture 8: Oxidation. Lecture

TOEFL Listening Lecture 35 184 TOEFL Listening Lecture 36 189 TOEFL Listening Lecture 37 194 TOEFL Listening Lecture 38 199 TOEFL Listening Lecture 39 204 TOEFL Listening Lecture 40 209 TOEFL Listening Lecture 41 214 TOEFL Listening Lecture 42 219 TOEFL Listening Lecture 43 225 COPYRIGHT 2016

Partial Di erential Equations MSO-203-B T. Muthukumar tmk@iitk.ac.in November 14, 2019 T. Muthukumar tmk@iitk.ac.in Partial Di erential EquationsMSO-203-B November 14, 2019 1/193 1 First Week Lecture One Lecture Two Lecture Three Lecture Four 2 Second Week Lecture Five Lecture Six 3 Third Week Lecture Seven Lecture Eight 4 Fourth Week Lecture .

This handbook supplement applies to students entering the fourth year of their degree in Computer Science, Mathematics & Computer Science or Computer Science . Undergraduate Course Handbook 1.2 Mathematics & Computer Science The Department of Computer Science offers the following joint degrees with the Department of Mathematics: BA .

COMPUTER NETWORKS Lecture Notes Course Code - BCS-308 Course Name - INTERNET & WEB TECHNOLOGY-I (3-1-0) Cr.-4 DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING, IT . Lecture 18 Networking protocols: Network Protocol Overview: Networking protocols in TCP/IP Lecture 19 Networking protocols in TCP/IP -ARP,RARP,BGP,EGP Lecture 20 NAT, DHCP .

Week 3 Lecture 3: Unix and You 1 / 50 / Announcements Basic 2, and Advanced 2 are out Lecture 2 survey is closing today Lecture 3: Unix and You 2 / 50 / Unix and You Lecture 3 Where I try not to turn this into an OS lecture Lecture 3: Unix and You 3 / 50 / Overview 1. What is Unix? 2. How d