4330/6310 FIRST ASSIGNMENT Spring 2015 Jehan-François Pâris

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

PROCESS MANAGEMENT. Contents   Process concept   Process states   Process description.
Real-Time Library: RTX
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Virtual Memory Introduction to Operating Systems: Module 9.
Programming Types of Testing.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Unit : Overview of Queues.
1 Friday, June 16, 2006 "In order to maintain secrecy, this posting will self-destruct in five seconds. Memorize it, then eat your computer." - Anonymous.
Input/Output Management and Disk Scheduling
Process Description and Control Module 1.0. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Computer Organization and Architecture
CPU-Scheduling Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The short term scheduler.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
Chapter 6 CPU SCHEDULING.
CHP-4 QUEUE.
CS 450 Module R6. Next Week R5 is due Friday after Break ( April 1st ) ▫No documentation, no source code due ▫R5 is stand-alone, so I will not be checking.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 23 Classic Synchronization.
Chapter 4. INTERNAL REPRESENTATION OF FILES
6 Memory Management and Processor Management Management of Resources Measure of Effectiveness – On most modern computers, the operating system serves.
Chapter 11 Heap. Overview ● The heap is a special type of binary tree. ● It may be used either as a priority queue or as a tool for sorting.
Indexed and Relative File Processing
Device Drivers CPU I/O Interface Device Driver DEVICECONTROL OPERATIONSDATA TRANSFER OPERATIONS Disk Seek to Sector, Track, Cyl. Seek Home Position.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS3: Concurrency 3.3. Advanced Windows Synchronization.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Queue Manager and Scheduler on Intel IXP John DeHart Amy Freestone Fred Kuhns Sailesh Kumar.
Lecture 12 Page 1 CS 111 Online Using Devices and Their Drivers Practical use issues Achieving good performance in driver use.
Fall 2000M.B. Ibáñez Lecture 26 I/O Systems II. Fall 2000M.B. Ibáñez Application I/O Interface I/O system calls encapsulate device behaviors in generic.
CHP-4 QUEUE Cont…. 7.DEQUE Deque (short form of double-ended queue) is a linear list in which elements can be inserted or deleted at either end but not.
Process Control Management Prepared by: Dhason Operating Systems.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Basic Concepts Maximum CPU utilization obtained with multiprogramming
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
Scheduling.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Memory Management.
Data Structures Using C, 2e
Queues.
Copyright ©: Nahrstedt, Angrave, Abdelzaher
Chapter 2 Memory and process management
Copyright ©: Nahrstedt, Angrave, Abdelzaher
Lectures Queues Chapter 8 of textbook 1. Concepts of queue
CPU scheduling 6. Schedulers, CPU Scheduling 6.1. Schedulers
System Structure and Process Model
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
Process Management with OS
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Operating System Concepts
Main Memory Background Swapping Contiguous Allocation Paging
Operating Systems.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Uniprocessor scheduling
Database Systems (資料庫系統)
CPU SCHEDULING CPU SCHEDULING.
COMP755 Advanced Operating Systems
Lecture 12 Input/Output (programmer view)
Presentation transcript:

4330/6310 FIRST ASSIGNMENT Spring 2015 Jehan-François Pâris

The model We have One quad-core CPU One disk One input device Three queues  CPU queue "ready queue"  Disk queue  Device queue RQRQ DQDQ Disk CC CC IQIQ Input

AN EXAMPLE

P0 begins at t = 0 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 RQRQ DQDQ Disk CC CC IQIQ Input NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40

P0 gets core until t = = 200 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 RQRQ DQDQ Disk CC CC IQIQ Input NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40

What's next? RQRQ DQDQ Disk CC CC IQIQ Input NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40

P1 arrives at t = 100 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

P1 gets core until t = = 130 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

What's next? NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

P1 waits for input until t = = 930 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

What's next? NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

P0 waits for input device NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

What's next? NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

P1 gets core until t = = 970 P0 waits for input until t = = 1830 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

What's next? NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

P1 terminates at t = 970 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

Your program will display (I) Process 1 terminates at t = 970 Core 0 is IDLE Core 1 is IDLE Core 2 is IDLE Core 3 is IDLE Disk is IDLE Average number of busy cores: Ready queue contains: -- Disk queue contains: --

Your program will display (II) Process IDStart timeCPU timeStatus 00200WAITING TERMINATED

How to compute CPU utilization Keep track of total time for all CPU requests: = 270 ms Divide by elapsed time:  270/970 = (rounded) Since there are four cores, the maximum CPU utilization is 4.0

What's next? NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

P0 gets core until t = = 1840 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

What's next? NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

P0 gets disk until t = = 1850 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

What's next? NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

P0 gets CPU until t = =1880 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

What's next? NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

P0 terminates at t = 1880 NEW 0 START 0 CPU 200 INPUT 900 CPU 10 I/O 10 CPU 30 NEW 1 START 100 CPU 30 INPUT 800 CPU 40 RQRQ DQDQ Disk CC CC IQIQ Input

Your program will display (I) Process 0 terminates at t = 1880 Core 0 is IDLE Core 1 is IDLE Core 2 is IDLE Core 3 is IDLE Disk is IDLE Average number of busy cores: Ready queue contains: -- Disk queue contains: --

Your program will display (II) Process IDStart timeCPU timeStatus 00240TERMINATED

How to compute CPU utilization Keep track of total time for all CPU requests: = 310 ms Divide by elapsed time:  310/1880 = (rounded) Since there are four cores, the maximum CPU utilization is 4.0

HANDLING ZERO-DELAY DISK ACCESSES

Zero-delay disk accesses Represent disk requests that can be satisfied without actually accessing the disk:  Data can be read from the I/O buffer  Data are written to the I/O buffer A process performing a zero-delay I/O request will:  Skip the disk  Start without further delay its next processing step

An example (I) … CPU 5 I/O 0 CPU 20 … RQRQ DQDQ Disk CC CC IQIQ Input Assume next step for red process is I/O 0

An example (II) … CPU 5 I/O 0 CPU 20 … RQRQ DQDQ Disk CC CC IQIQ Input Red process will immediately request a core (and get one because one or more cores were idle)

ENGINEERING THE SIMULATION

Simulating time Absolutely nothing happens to our model between two successive "events" Events are  Arrival of a new process  Start of a computing step  Completion of a computing step We associate an event routine with each event

Arrival event routine Process first request of process  It will always be a CPU request

CPU request routine current time is clock request time is crt if a core is free : mark core busy until clock + crt add crt to corebusytimes else : enter process in ready queue

CPU request completion routine if ready queue is empty : mark core idle else: pick first process P' in ready queue crt' is request time for P' mark core busy until clock + crt' add crt' to corebusytimes proceed with next request for completing process

Disk request routine current time is clock request time is drt if drt == 0: proceed with next process request if disk is free : mark disk busy until clock + drt add drt to diskbusytimes else : enter process request in disk queue

Disk request completion routine if disk queue is empty : mark disk idle else : pick first process request P' in disk queue drt' is request time for P' mark disk busy until clock + drt' add drt' to diskbusytimes proceed with next request for completing process

Input request routine current time is clock request time is irt if input device is free : mark input device busy until clock + irt else : enter process request in device queue

Input request completion routine if input queue is empty : mark input device idle else : pick first process request P' in input queue irt' is request time for P' mark disk busy until clock + irt' proceed with next request for completing process

The simulation scheduler 1.Find next event by looking at: CPU request completion times Disk request completion time time Input request completion time Arrival time of next process 2.Set current time to event time 3.Process event routine 4.Repeat until all processes are done

Organizing our program (I) Most steps of simulation involve scheduling future completion events Associate with each completion event an event notice  Time of event  Device  Process sequence number

Organizing our program (II) Do the same with process starts  Time of event  Process start  Process sequence number

Organizing our program (III) Process all event notices in chronological order Release disk 247 Release core 250 New process 245 New process 270 New process 310 First notice to be processed

Organizing our program (IV) Keep the event list sorted (priority queue) Release disk 247 Release core 250 New process 245 New process 270 New process 310 First notice to be processed is head of the list

Organizing our program (V) Overall organization of main program schedule first event # will be a process start while event list is not empty : process next event in list print simulation results

Organizing our event list Priority queue Two kinds of entries  Computational steps completion times: Created and inserted "on the fly"  Process arrivals: Created during input phase Already sorted

An implementation My main data structures would be:  Data table  Process table  Device table

The data table Stores the input data Line indices are used in process table OperationParameter NEW 5 CPU 10 INPUT 0 CPU 20 NEW 20 CPU 50 … …

The process table (I) Start Time First Line Last Line Current Line 503 varies 204…… …………

The process table (I) Start Time First Line Last Line Current Line 503 varies 204…… …………

The process table (II) One line per process  Line index is process sequence number! First column has start time of process First line, last line and current line respectively identify first line, last line and current line of the process in the input table Last column is for processes waiting for end of an INPUT step

The device table (I) ProcessCompletion time P First column is not needed: use row index to specify device

The device table (II) One line per device (core, disk and Input) Contains  A busy/free flag  A process sequence number if device is busy  A completion time Zero (or a very large value) if device is free

Finding the next event (I) If you use a priority list for your events, you should start by "seeding" your priority list with the arrival times of all processes After that, you add successive events to the list each time you can allocate a resource to a process. Your simulation will end once the list is empty (and you cannot add anything to it).

Finding the next event (II) If you do not use a priority list for your events, you can find the next event to process by searching the lowest value in  The process start times in the process table  Completion times of INPUT steps  The completion times in the device table

A full list implementation INT… 0 INT… 5 RUN 10 RUN 20 … … … Very elegant but harder to debug

Reading your input You must use I/O redirection  assign1 < input_file Advantages  Very flexible  Programmer writes her code as if it was read from standard input No need to mess with fopen(), argc and argcv