lect15 - CMSC 216 Introduction to Computer Systems Lecture...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CMSC 216 Introduction to Computer Systems Lecture 15 Process Control Jan Plane & Pete Keleher {jplane,keleher}@cs.umd.edu Administrivia • P3 due Sunday 6pm – late period until today at 6pm • Project 4 posted – due Nov 6 – There are a lot of functions – implement and test those independently rather than writing the whole thing at one time and then testing!!! • Read Sections 8.2-8.5, on process control 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
P ROCESS C ONTROL Sections 8.2-8.5, Bryant and O'Hallaron 3 Processes • Definition: "an instance of a program in execution" • A process provides a context for the executing program: current memory state, open files, register contents, PC, environment variables • When you type in the name of a program in the shell, the shell creates a new process in which that program will run 4
Background image of page 2
Multitasking • Even though it appears to us that many programs run at the same time, in reality, only one process is able to use a CPU at a time • The CPU is divided between all the currently running processes by the OS, which forces processes to be suspended • To each process, it appears as if the process has sole control of the CPU, and logical flow of one process isn't affected by others (except for IPC) 5 Multitasking example 6 A B C D A C Time
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
User and kernel modes • Some instructions are restricted (or privileged ), so that only the OS can execute them – e.g., halting the CPU, performing I/O, creating processes • When a process needs to do one of these things, the process must enter kernel mode • Normally, processes are in user mode 7 User and kernel modes, cont. • When in user mode, trying to perform a privileged instruction or access kernel-reserved memory results in a fatal protection fault • Should a process need to do one of these things, it needs to use the system call interface to access these instructions/areas of memory 8
Background image of page 4
Implementation of multitasking • To move processes in and out of the CPU, the kernel needs to maintain the context (execution state) of each process • Data structures used to maintain context: – page table, stores processes' address spaces – process table, stores information about each process – file table, lists which files are opened by each process 9 Context switching • When a process is to be moved out of the CPU, the context is saved and the context of the incoming process is restored • This is how the kernel schedules processes in the CPU • Processes can be switched out whenever the kernel deems it necessary or appropriate – when a process is waiting for I/O – when a process has been using the CPU for a long time 10
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
System calls • "The system call is the fundamental interface between an application and the Linux kernel." -- the syscalls manual page • System calls include functions to do things like – open/close/create/delete files – read from/write to files – create processes – read the system clock 11 Error handling When a system call fails, it sets the global integer
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/13/2012 for the course CMSC 216 taught by Professor Plane during the Spring '11 term at Maryland.

Page1 / 16

lect15 - CMSC 216 Introduction to Computer Systems Lecture...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online