Class Note for CMPSCI 377 at UMass(2)
Class Note for CMPSCI 377 at UMass(2)
Popular in Course
Popular in Department
This 3 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Massachusetts taught by a professor in Fall. Since its upload, it has received 18 views.
Reviews for Class Note for CMPSCI 377 at UMass(2)
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
CMPSCI 377 Operating Systems Fall 2005 Lecture 4 September 22 Lecturer Emery Berger Scribe Andrey Ostapchenko and Nikita varwv Today 0 OS Structures and Processes 41 Processes OS executes variety of programs Batch System jobs run one after the other TimeShared systems user programs or tasks De nition 41 A process is a fundamental schedulable unit of execution At minimum each process includes 0 Program counter stack location 0 Stack variable values 0 Data section global variables address space Process states New being created ile process goes into memory from the disk Running instructions being executed Waiting waiting for some event to occur ilel awaiting data from disk Ready waiting to be assigned to a processor Terminated selfexplanatory Zombie useless children processes spawned by a parent process that has crashed Processes usually loop between 3 states running waiting ready Transitions from one state to another usually happen on program actions OS actions or interrupts As an example in UNIX a user can choose to run the process and wait until it nishes or run it in background Sequential run cp r foo bar That will recursively copy foo into bar and then prompt for another command Background run cp r foo bar amp That will run the same process but user will be able to continue working while the process is running 4 1 4 2 Lecture 4 September 22 411 Process Control Block De nition 42 AP39rocess Control Block or PCB tracks process state such as program counter cpu registers 0 status memorymanagement As an example of a poorly designed PCB consider the following in Linux process identi ers are limited to 1024 If the number of processes increases past that number the operating system will crash Note that it is expensive to switch between processes When a user switches from one process to another TLB needs to be ushed and repopulated Memory cache is useless cold so it needs to be renewed The OS usually tries to solve this problem by scheduling each process to run for a speci c period of time This job is handled by the scheduler using queues Scheduler queues Job queue the set of all processes in a system Ready queue set of processes residing in main memory ready and waiting to be executed Device queue set of processes waiting for lO device one per device These queues are simple linked lists Same item can be placed on more than one queue at the same time 42 Forking It is possible for one process to create another process this is called forking The creator is called the parent process and the new processes are called children processes A parent process can wait for the children processes to complete or it can continue running in parallel UNIX forko copies variablesregisters from parent to child Memory lazily copied copyonwrite by reference The only difference between parent and child is the return value parent returns pid process ID of child child returns 0 On termination of a process the operating system reclaims all resources UNIX processes have the ability to terminate themselves via the exit system call they can also terminate child processes via the kill system call Processes can also cooperate and work together on a task This may improve performance and yield possible simpler program design Lecture 4 September 22 43 43 Process Communication Processes sometimes need to exchange information between themselves This can be done in two ways 0 Message passing sendreceive information via sockets pipes 0 Shared memory establish mapping to named memory object use mmap 7 forhO processes to share the structure 44 Process a unit of execution Process is represented by Process Control Blocksi They contain process state scheduling info etc A uniprocessor system can only have one running process at a time so context switch is used to alternate between processes De nition 43 Quantum is the maximum time the process is allowed to run by the scheduler before it gets placed back in queue or nishes and terminates Since a process can only run for a limited time quantum execution time needs to be divided into quanta for every process That is called Time Slicingi
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'