DOC PREVIEW
UCSD CSE 120 - I/O and 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:

Lecture 3:Lecture 3:I/OI/O and Processesand ProcessesCSE 120: Principles of Operating SystemsAlex C. SnoerenLab 0 & HW 1 Due Tuesday 10/03CSE 120 – Lecture 3: Processes 2Input/Output (I/O)Input/Output (I/O) Input and Output devices operate independently of main CPU◆ Speeds vary; often much slower than CPU instructions◆ Device uses interrupts to signal OS when ready/done» Have you ever heard of an IRQ (Interrupt Request Level)? I/O devices are managed by the OS◆ Enforces sharing, protection◆ Requires privileged instructions to initiate I/O◆ Kernel maintains table to map device interrupts to handlers, a.k.a devicedrivers Communication handled through memory abstraction◆ Device buffers and registers mapped into address space◆ Data copied into address range send data to I/O deviceCSE 120 – Lecture 3: Processes 3I/O ExampleI/O Example1) Ethernet receives packet, writes packet into buffer2) Network Interface Card (NIC) signals an interrupt3) CPU stops current instruction, saves current context4) CPU reads handler address from kernel vector table,indexed by IRQ, jumps to appropriate address(Ethernet driver)5) Ethernet device driver reads packet from buffer,processes packet6) Kernel restores saved context, reissues interruptedinstructionCSE 120 – Lecture 3: Processes 4Interrupt IssuesInterrupt IssuesOperating SystemHardwareApplications Interrupts suspend current process and transfercontrol to the OS◆ Can the OS itself be interrupted?◆ Sometimes interrupts need to be masked until the OS is readyto handle them Interrupts are default model for device interaction◆ What is the alternative?◆ What are the drawbacks of the alternative approach?◆ When might an OS want to avoid interrupts?CSE 120 – Lecture 3: Processes 5AtomicityAtomicity Interrupts are pesky◆ They can occur at any time, including inconvenient ones◆ In particular, a handler may interfere with currently executingcode paths» Can a handler interrupt itself? OS needs some way to ensure certain instructions orsequence of instructions are not interrupted◆ One option is to disable interrupts during critical section◆ Another alternative is to have special atomic instructions» Guaranteed not to be interrupted» E.g., test and conditionally set a bit based on previous value What if the machine has more than one CPU?CSE 120 – Lecture 3: Processes 6Coordinating ExecutionCoordinating Execution This lecture starts a class segment that coversprocesses, 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 processmanagement◆ 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?CSE 120 – Lecture 3: Processes 7The ProcessThe 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 asequential process. A sequential process is a program in execution◆ It defines the sequential, instruction-at-a-time execution of aprogram◆ Programs are static entities with the potential for executionCSE 120 – Lecture 3: Processes 8Process ComponentsProcess Components A process contains all of the state for a program inexecution◆ 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)CSE 120 – Lecture 3: Processes 9Process Address SpaceProcess Address SpaceStack0x000000000xFFFFFFFFCode(Text Segment)Static Data(Data Segment)Heap(Dynamic Memory Alloc)AddressSpaceSPPCCSE 120 – Lecture 3: Processes 10Process StateProcess State A process has an execution state that indicates what itis 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?CSE 120 – Lecture 3: Processes 11Process State GraphProcess State GraphNew ReadyRunningWaitingTerminatedCreateProcessProcessExitI/O, PageFault, etc.I/O DoneScheduleProcessUnscheduleProcessCSE 120 – Lecture 3: Processes 12Process Data StructuresProcess 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 iscalled 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.) whenthe process is not running◆ This state is everything that is needed to restore the hardwareto the same configuration it was in when the process wasswitched out of the hardwareCSE 120 – Lecture 3: Processes 13PCB Data StructurePCB Data Structure The PCB contains a huge amount of information inone 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 abstractionCSE 120 – Lecture 3: Processes 14PCBs and Hardware StatePCBs and Hardware State When a process is running, its hardware state (PC,SP, regs, etc.) is in the CPU◆ The hardware registers contain the current values When the OS stops running a process, it saves thecurrent values of the registers into the process’ PCB When the OS is ready to start executing a newprocess, it loads the hardware registers from thevalues


View Full Document

UCSD CSE 120 - I/O and 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

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 I/O and 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 I/O and 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 I/O and 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?