Elevator problem • Let us define the elevator problem as: – We need to move n elevators between m floors. 1. Each elevator has a set of m buttons, one for each floor. These illuminate when pressed and cause the elevator to visit the corresponding floor. The illumination is cancelled when the corresponding floor is visited by the elevator 2. Each floor, except the first floor and the top floor has two buttons, one to request an up-elevator, and one to request a down-elevator. These buttons illuminate when pressed. The illumination is cancelled when an elevator visits the floor and then moves in the desired direction. 3. When an elevator has no requests, it remains at tis current floor with its doors closed. CS460 - Senior Design Project I (AY2004) 9
Petri nets – elevator problem • • • • • There are n elevators installed in a building with m floors. Each floor is represented by a place, F f, 1 ≤ f ≤ m. An elevator is represented by a token. A token in Ff denotes that an elevator is at floor f. Constraint – Each elevator has a set of m buttons – one for each floor. – These are illuminated when pressed, cause the elevator to travel to that floor, and turned off when the elevator arrives at that floor. – Additional places are needed to model this. • The elevator button for floor f in elevator e is denoted EB f, e with 1 ≤ f ≤ m, 1 ≤ e ≤ n • For the sake of simplicity we suppress the subscript e denoting the elevator. CS460 - Senior Design Project I (AY2004) 24
Disk Scheduling SCAN Disk Scheduling works like an elevator – An elevator is designed to visit floors that have people waiting. In general, an elevator moves from one extreme to the other (say, the top of the building to the bottom), servicing requests as appropriate – The SCAN disk-scheduling algorithm works in a similar way, except instead of moving up and down, the read/write heads move in toward the spindle, then out toward the platter edge, then back toward the spindle, and so forth 27
Disk Scheduling SCAN Disk Scheduling works like an elevator – An elevator is designed to visit floors that have people waiting. In general, an elevator moves from one extreme to the other (say, the top of the building to the bottom), servicing requests as appropriate – The SCAN disk-scheduling algorithm works in a similar way, except instead of moving up and down, the read/write heads move in toward the spindle, then out toward the platter edge, then back toward the spindle, and so forth 28
SCAN (Elevator) and C-Scan SCAN: Service the first request encountered in the current head direction C-Scan: Services in one direction; SCAN: Services in both directions C-Scan: Return to the beginning after each pass (circular list) Head going left Movement = 236 cylinders Head going right Movement = 382 cylinders • C-Scan: Provides a more uniform wait time than SCAN. • Repositioning to the beginning is faster than repositioning in small pieces because of acceleration and deceleration.
Finite state machines • In each of the n elevators, there are m buttons – one for each floor. These are called elevator buttons (EB). • One each floor there are two buttons to request an up and down elevator. These are called floor buttons (FB). • Let EB(e, f) denote the button in elevator e that is pressed to request floor f. • EB(e, f) can be in two states: – EBON(e, f): Elevator Button (e, f) ON. – EBOFF(e, f): Elevator Button (e, f) OFF. • If the button is on and the elevator arrives at floor f, then the button is turned off. If the button is off, and it is pressed, then the button comes on. • These two events are: – EBP(e, f): Elevator Button (e, f) Pressed. – EAF(e, f): Elevator e Arrives at Floor f. CS460 - Senior Design Project I (AY2004) 10