ID.1CSMC 412CSMC 412Operating SystemsProf. Ashok K Agrawala© 2006 Ashok AgrawalaSet IDID.2Operating SystemOperating Systemas as Decision MakerDecision Maker All resource management decisions are taken by the OS What information does it have to base those decisions on?z It has to collect and keep that information z Make sure that the information is not corruptedz Update as necessaryz Use it Where to keep information about entities under its control?z Control Blocks All information is collected at a time instantz There is always a delay between collecting the information and using it. z Is it valid and correct when it is used in decision making?ID.3Information Based Decision MakingInformation Based Decision Making A decision requires information The information available to the decision maker z Designed as a part of the system designz In the address space of the executing unit taking the decision- OS Have to recognize independent action unitsz A unit that continues to operate once triggered CPU Clock Disk Disk controller … Every Action has to be triggered from external source at some point.ID.4Using Information in DecisionsUsing Information in Decisions Access information Decide Initiate action Modify information Shared memory vs. messagesCan information Change during this period?ID.5Concurrent ExecutionsConcurrent Executions When there are concurrent executions the actions of one process can be affected by the action of another process at any stage ofexecution –z Unless appropriate protection measures are taken One way of protectionz Isolate independent processes But they do share resources – would that cause conflicts?? Cooperating processesz Have to communicate/sharez Thus they interactID.6ExampleExample A program in executionAddressspaceGPRsIRPS……MemProcessControl InfoCPUID.7Time QuantumTime Quantum Time quantum for an executing processClockClock RegInterrupt FlagAddressspaceGPRsIRPS……MemProcessControl InfoCPUID.8CommunicationCommunication Receiver must be ready to receivez Prior Arrangementz Coordinate in timez Use a Buffer –Solves immediate problem –but !!SenderReceiverSenderReceiverBufferID.9Producer ConsumerProducer Consumer One process generates data – the producer The other process uses it – the consumer If directly connected – time coordinationz How would they coordinate the time ??ProducerConsumerID.10Producer ConsumerProducer Consumer One process generates data – the producer The other process uses it – the consumer If not directly connected – have a bufferz Buffer must be accessible to bothz Finite Capacity N – Number in use - KProducerConsumerBufferID.11CoordinationCoordination Number full – Kz Incremented by Producerz Decremented by ConsumerRead KIncrementStore KRead KDecrementStore KID.12Information Needed Information Needed by Producer/Consumerby Producer/Consumer Producerz There is an empty bufferz Empty buffer IDz Nobody else is using this buffer for filling or emptyingz Inform others that it is using this buffer. Consumerz There is a full bufferz Full buffer IDz Nobody else is using this buffer for filling or emptyingz Inform others that it is using this buffer.ID.13Mutual ExclusionMutual Exclusion N processes Each has a portion of the code called Critical Section At any instant no more than one process can be in its critical section What should a process do ???CSCSCSCSID.14Critical SectionCritical Section Entry and Exit Code Entry Codez Code to ascertain that this process can enter the CSz Make sure that other processes know that this process has entered CS Exit Codez Let other processes know that it has exited from its CS HOW ???CSCSEntry CodeExit CodeID.15Atomic ActionAtomic Action An action that is either completely done or not done at allz Can not be accessed or affected in the middle of its execution Necessary for z Accessing the informationz Take decisionz Modify the informationID.16SynchronizationSynchronization Controlling the execution of processes to conform to stated/required timing/precedence relationships among eventsz Precedence A must occur before Bz Mutual Exclusionz Producer Consumerz More complex relationships Recognizing the information needs for any such decisions does make the design
View Full Document