Instructor: Anirban Mahanti Office: ICT 745 Class Location: TRB 101

Slides:



Advertisements
Similar presentations
Chapter 2 Modeling Complex Systems
Advertisements

E&CE 418: Tutorial-4 Instructor: Prof. Xuemin (Sherman) Shen
Modeling & Simulation. System Models and Simulation Framework for Modeling and Simulation The framework defines the entities and their Relationships that.
Lab Assignment 1 COP 4600: Operating Systems Principles Dr. Sumi Helal Professor Computer & Information Science & Engineering Department University of.
 1  Outline  performance measures for a single-server station  discrete-event simulation  hand simulation  process-oriented simulation approach.
 Basic Concepts  Scheduling Criteria  Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 19 Scheduling IV.
Lecture 13 – Continuous-Time Markov Chains
WELCOME TO THETOPPERSWAY.COM
Components and Organization of Discrete-event Simulation Model
Simulation with ArenaChapter 2 – Fundamental Simulation Concepts Discrete Event “Hand” Simulation of a GI/GI/1 Queue.
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
CPSC 531: DES Overview1 CPSC 531:Discrete-Event Simulation Instructor: Anirban Mahanti Office: ICT Class Location:
Lab 01 Fundamentals SE 405 Discrete Event Simulation
 1  Outline  simulating GI/G/1 queues  M/M/1 queues  theoretical results of queueing systems  an inventory system  simulation program with an event.
Graduate Program in Engineering and Technology Management
Slide - 1 Dr Terry Hinton 6/9/05UniS - Based on Slides by Micro Analysis & Design An example of a Simulation Simulation of a bank: Three tasks or processes:
Chapter 6: CPU Scheduling
CHP-4 QUEUE.
Verification & Validation
ETM 607 – Discrete Event Simulation Fundamentals Define Discrete Event Simulation. Define concepts (entities, attributes, event list, etc…) Define “world-view”,
CPSC 531: Probability Review1 CPSC 531:Probability & Statistics: Review II Instructor: Anirban Mahanti Office: ICT 745
+ Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
Chapter 2 – Fundamental Simulation ConceptsSlide 1 of 46 Chapter 2 Fundamental Simulation Concepts.
SIMULATION EXAMPLES QUEUEING SYSTEMS.
SIMULATION OF A SINGLE-SERVER QUEUEING SYSTEM
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Chapter 2 Fundamental Simulation Concepts
MODELING EXAMPLES Types of model Conceptual Containing components that have not been clearly Identified in terms of theoretic categories such as state,
(C) J. M. Garrido1 Objects in a Simulation Model There are several objects in a simulation model The activate objects are instances of the classes that.
SIMULATION EXAMPLES. Monte-Carlo (Static) Simulation Estimating profit on a sale promotion Estimating profit on a sale promotion Estimating profit on.
CPSC 531: DES Overview1 CPSC 531:Single-Server Simulation Instructor: Anirban Mahanti Office: ICT Class Location: TRB.
Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.
Simulation Examples And General Principles Part 2
Queuing Theory Simulation & Modeling.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
CPU Scheduling CS Introduction to Operating Systems.
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
Operating Systems (CS 340 D)
Chapter 5a: CPU Scheduling
Modeling and Simulation CS 313
Operating Systems (CS 340 D)
Chapter 6: CPU Scheduling
ECE 358 Examples #1 Xuemin (Sherman) Shen Office: EIT 4155
Process Scheduling B.Ramamurthy 11/18/2018.
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 2 Modeling Complex Systems (cont’d.)
3: CPU Scheduling Basic Concepts Scheduling Criteria
Process Scheduling B.Ramamurthy 12/5/2018.
Chapter5: CPU Scheduling
Chapter 6: CPU Scheduling
Lecture 2 Part 3 CPU Scheduling
Discrete Event “Hand” Simulation of a GI/GI/1 Queue
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Chapter 6: CPU Scheduling
Chapter 4: Simulation Designs
MECH 3550 : Simulation & Visualization
Module 5: CPU Scheduling
CSCS-200 Data Structure and Algorithms
Chapter 6: CPU Scheduling
MECH 3550 : Simulation & Visualization
Module 5: CPU Scheduling
Presentation transcript:

CPSC 531: Some more examples – Time-shared computer and multi-teller bank Instructor: Anirban Mahanti Office: ICT 745 Email: mahanti@cpsc.ucalgary.ca Class Location: TRB 101 Lectures: TR 15:30 – 16:45 hours Class web page: http://pages.cpsc.ucalgary.ca/~mahanti/teaching/F05/CPSC531/ Notes derived from “Simulation Modeling and Analysis” by A. Law and W. Kelton, Third edition, McGraw Hill, 2000. CPSC 531: Simulation Examples

Objective Under simulation fundamentals via examples Time-shared computer model Multi-teller bank with jockeying Job shop model Get a grip of “simlib” CPSC 531: Simulation Examples

Time-Shared Computer Model CPSC 531: Simulation Examples

Problem Specification Terminals “think” and then issue jobs Think times exponentially distributed - 25 s Job service times also exponentially distributed - 0.8 s Job processing rule: round-robin Each visit to CPU is  q = 0.1 sec. (a quantum) If remaining processing requirement > q sec., it gets q sec, then kicked out If remaining processing requirement  q sec., it gets what it needs, returns to its terminal Other job processing possibilities: FIFO, SJF, LIFO etc. Swap time:  = 0.15 sec. Elapse whenever a job enters CPU before processing starts CPSC 531: Simulation Examples

Problem Specification Response time of a job = (time job returns to terminal) – (time it left its terminal) Initially, computer empty and idle, all n jobs in the think state at their terminals Stopping rule: 1000 response times collected Output: Average of the response times Time-average number of jobs in queue for the CPU CPU utilization Question: how many terminals (n) can be loaded on and hold average response time to under 30 s? CPSC 531: Simulation Examples

Turning the specifications to a prog. Job Arrival CPU Processing End Simulation Terminals CPSC 531: Simulation Examples

Simlib program: events, lists, etc 1 = Arrival of a job to the computer (at end of a think time) 2 = A job leaves the CPU (done or kicked out) 3 = End simulation (scheduled at time 1000th job gets done) (Also, have “utility” non-event function start_CPU_run to remove first job from queue, put it into the CPU) simlib lists, attributes: 1 = queue, attributes = [time of arrival of job to computer, remaining service time] 2 = CPU, attributes = [time of arrival of job to computer, remaining service time] In CPU, if remaining service time > 0 then job has this much CPU time needed after current CPU pass; if remaining service time  0, job will be done after this pass 25 = event list, attributes = [event time, event type] CPSC 531: Simulation Examples

Simlib program: variables, random streams sampst variable: 1 = response times timest variables: none (use filest on the lists) Random-number streams: 1 = think times, 2 = service times CPSC 531: Simulation Examples

Overview of function main() /* ……… code fragment from main() ……….. */ for (num_terms = min_terms; num_terms <= max_terms; num_terms += incr_terms) { init_simlib(); /* Initialize simlib */ maxatr = 4; /* NEVER SET maxatr TO BE SMALLER THAN 4. */ num_responses = 0; /* Initialize the non-simlib statistical counter. */ for (term = 1; term <= num_terms; ++term) /* Schedule the first arrival to the CPU from each terminal. */ event_schedule(expon(mean_think, STREAM_THINK), EVENT_ARRIVAL); do { timing(); /* Determine the next event. */ /* Invoke the appropriate event function. */ switch (next_event_type) { case EVENT_ARRIVAL: arrive(); break; case EVENT_END_CPU_RUN: end_CPU_run(); case EVENT_END_SIMULATION: report(); } } while (next_event_type != EVENT_END_SIMULATION); CPSC 531: Simulation Examples

The arrive() function Function arrive() Place job in queue CPU idle? Yes No Return Start CPU run CPSC 531: Simulation Examples

The arrive() function void arrive(void) /* Event function for arrival of job at CPU after think time. */ { /* Place the arriving job at the end of the CPU queue. Note that the following attributes are stored for each job record: 1. Time of arrival to the computer. 2. The (remaining) CPU service time required (here equal to the total service time since the job is just arriving). */ transfer[1] = sim_time; transfer[2] = expon(mean_service, STREAM_SERVICE); list_file(LAST, LIST_QUEUE); /* If the CPU is idle, start a CPU run. */ if (list_size[LIST_CPU] == 0) start_CPU_run(); } CPSC 531: Simulation Examples

The start_CPU_run() function CPSC 531: Simulation Examples

The end_CPU_run() function CPSC 531: Simulation Examples

Things to do Look at the simlib code for the time shared computer model Try problem 2.3 from the LK00 text book Our next stop will be Multi-teller Bank with Jockeying CPSC 531: Simulation Examples

Multi-teller Bank New arrivals: Initially empty and idle Interarrival times: Expon (mean = 1 min.) Service times: Expon (mean = 4.5 min.) New arrivals: If there’s an idle teller, choose leftmost (idle) teller If all tellers are busy, choose shortest queue (ties – leftmost) Initially empty and idle Termination: close doors at time 480 min. If all tellers are idle at that time, stop immediately If any tellers are busy, operate until all customers leave service CPSC 531: Simulation Examples

Jockeying Rules Suppose teller i (i fixed) finishes service — e.g., i = 3 above Then either teller i becomes idle, or queue i becomes one shorter Maybe a customer at the end of some other queue j ( i) moves to teller i (if now idle) or the end of the now-shorter queue i For each teller/queue k, let nk = number of customers facing (in queue + in service) teller k just after teller i finishes service Procedure: If nj > ni + 1 for some j  i, then a jockey will occur If nj > ni + 1 for several values of j  i, pick the closest j (min |j – i|) If nj > ni + 1 for two equally closest (left and right) values of j  i, pick the left (smaller) value of j CPSC 531: Simulation Examples

Performance Metrics Estimate Time-average total number of customers in (all) queues Average, max delay of customers in queue(s) What’s the effect of the number of tellers? CPSC 531: Simulation Examples

Simlib program: events, lists, etc 1 = Arrival of a customer to the bank 2 = Departure of a customer from a teller (need to know teller #) 3 = Close doors at time 480 min. (may or may not be The End) (Also, have “utility” non-event function jockey to see if anyone wants to jockey, and, if so, carry it out) simlib lists, attributes (n = number of tellers): 1, …, n = queues, attributes = [time of arrival to queue] n + 1, …, 2n = tellers, no attributes = (dummy lists for utilizations) 25 = event list, attributes = [event time, event type, teller number if event type = 2] CPSC 531: Simulation Examples

Simlib program: variables, streams sampst variable: 1 = delay of customers in queue(s) timest variables: none … use filest for time-average number in queues since time-average of total = total of time averages (details in book) Random-number streams: 1 = interarrival times, 2 = service times CPSC 531: Simulation Examples

The main() function // code fragment // … see text for the rest event_schedule(expon(mean_interarrival, STREAM_INTERARRIVAL), EVENT_ARRIVAL); /* Schedule the first arrival. */ /* Schedule the bank closing. (Note need for consistency of units.) */ event_schedule(60 * length_doors_open, EVENT_CLOSE_DOORS); /* Run the simulation while the event list is not empty. */ while (list_size[LIST_EVENT] != 0) { /* Determine the next event. */ timing(); /* Invoke the appropriate event function. */ switch (next_event_type) { case EVENT_ARRIVAL: arrive(); break; case EVENT_DEPARTURE: depart((int) transfer[3]); /* transfer[3] is teller number */ case EVENT_CLOSE_DOORS: event_cancel(EVENT_ARRIVAL); } CPSC 531: Simulation Examples

The arrive() function CPSC 531: Simulation Examples

The depart() function CPSC 531: Simulation Examples

The depart() function … void depart(int teller) /* Departure event function. */ { /* Check to see whether the queue for teller "teller" is empty. */ if (list_size[teller] == 0) /* The queue is empty, so make the teller idle. */ list_remove(FIRST, num_tellers + teller); else { /* The queue is not empty, so start service on a customer. */ list_remove(FIRST, teller); sampst(sim_time - transfer[1], SAMPST_DELAYS); transfer[3] = teller; /* Define before event_schedule. */ event_schedule(sim_time + expon(mean_service, STREAM_SERVICE), EVENT_DEPARTURE); } /* Let a customer from the end of another queue jockey to the end of this queue, if possible. */ jockey(teller); CPSC 531: Simulation Examples

The jockey() function CPSC 531: Simulation Examples

Things to do Look at the simlib code for the multi-teller bank model Try problem 2.4 from the LK00 text book Some food for thought How about replacing this multiple-teller multiple-queue model with a single-queue multiple-teller model? CPSC 531: Simulation Examples

Job Shop Model Five workstations Three types of jobs Number of identical machines at each workstation as shown Network of multiserver queues Three types of jobs Interarrival times (all job types combined) expon (mean = 0.25 hour) Job type determined just after arrival Type 1, 2, 3 w.p. 0.3, 0.5, 0.2 Workstation routes for job types: Type 1: 3  1  2  5 (see fig.) Type 2: 4  1  3 Type 3: 2  5  1  4  3 Mean service times (2-Erlang distrib.): Type 1: 0.50  0.60  0.85  0.50 Type 2: 1.10  0.80  0.75 Type 3: 1.20  0.25  0.70  0.90  1.0 Initially empty and idle Stop at time 365  8 hours CPSC 531: Simulation Examples

Job Shop Model (cont’d.) Estimate Average total delay in queues for each job type separately Overall average total delay in queues over all job types, weighted by their (known) probabilities of occurrence For each machine group separately: Average delay in queue there (all job types lumped together) Time-average number of jobs in queue (all job types together) Group utilization = Number of machines in the group Question: If you could add one machine to the shop, to which group should it go? Time-average number of machines that are busy Number of machines in the group CPSC 531: Simulation Examples

Simlib program: events, lists, etc 1 = Arrival of a job to the system 2 = Departure of a job from a particular station 3 = End of the simulation simlib lists, attributes: 1, …, 5 = queues, attributes = [time of arrival to station, job type, task number] 25 = event list, attributes = [event time, event type, job type (if event type = 2), task number (if event type = 2)] (Task number of a job is how far along it is on its route, measured in stations, so starts at 1, then is incremented by 1 for each station) CPSC 531: Simulation Examples

Simlib program: variables sampst variables: 1, …, 5, = delay in queue at machine group 1, …, 5 6, 7, 8 = total delay in queues for job type 1, 2, 3 timest variables: 1, …, 5 = number of machines busy at machine group 1, …, 5 (We’ll keep our own, non-simlib variable num_machines_busy[j] to track the number of machines busy in group j) Random-number streams: 1 = interarrival times, 2 = job-type coin flip, 3 = service times CPSC 531: Simulation Examples

Things to do Look at the simlib code for this problem Next class – continue with Statistical Models First assignment will be out this weekend CPSC 531: Simulation Examples