Interrupts - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Interrupts

Description:

It is an event because it occurs at a specific instant and has no duration ... deactivate(this); // suspend itself (C) J. M. Garrido. 14 ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 25
Provided by: josemg2
Category:

less

Transcript and Presenter's Notes

Title: Interrupts


1
Interrupts
2
An Interrupt
  • A signal sent to a process
  • An action taken by the interrupting process
  • It is an event because it occurs at a specific
    instant and has no duration
  • An interrupt is associated with and interrupt
    level

3
An Interrupt (Cont.)
  • A process interrupts the normal activity of
    another process
  • The first process is called the interrupting
    process, the second one is called the interrupted
    process
  • The interrupted process will later continue its
    activity from the point of interruption

4
The Interrupted Process
  • Decides what to do when it detects an interrupt.
  • Usually releases any resources held, saves the
    remaining service time, joins a queue, and
    suspends itself.
  • Can detect one or more levels of interrupt, each
    one can trigger a different response activity.

5
Interrupt Handling
  • When interrupted, a process executes an interrupt
    routine before suspending
  • In the interrupt routine, the process
  • Computes the remaining time
  • Releases resources
  • Other immediate activity
  • There is usually an interrupt routine for every
    interrupt level

6
Flow of Activity for Interrupt Routine
7
Interrupting and Interrupted Processes
8
Multi-Server Multi-Queue Model with Preemption
  • Every customer has a priority
  • An arriving customer can interrupt the service of
    another customer with a lower priority
  • The interrupted customer is returned to the head
    of his queue, this customer is the one with the
    lowest priority and that started most recently.

9
The Interrupting Process
  • Only sends an interrupt to a lower priority
    process
  • Waits for the availability of a server, after the
    interrupt
  • Waits for the availability of resources released
    by the interrupted process
  • Can determine the remaining time of the
    interrupted process.

10
After the Interrupt
  • The interrupting process gets access to server(s)
    and resources available
  • Then it can reactivate the interrupted process
  • Any other process can reactivate the interrupted
    process
  • The interrupted process resumes service for its
    remaining period, or can be interrupted again

11
Selection of the Process to Interrupt
  • The lowest priority process, lower than the
    priority of the interrupting process
  • If there are several processes with the same
    priority
  • the process that started most recently
  • the process that has the shortest remaining time
  • the process that started first

12
Interrupts with PsimJ
In the interrupting process int intr_level
1 // intrrupt level pp_object.p_interrupt(
intr_level) where pp_object is a reference to
the interrupted process and intr_level is the
interrupt level
13
Interrupted Process
  • The interrupted process executes the following
    code
  • if (int_level() 1) // interrupt level 1?
  • // ... execute interrupt service routine
  • deactivate(this) // suspend itself

14
Parts Replacement System With Interrupts
  • When a part fails, the machine object
  • Removes the damaged part
  • Place the damaged part in the container for
    damaged parts
  • Interrupt the repairman object if it is carrying
    out background tasks
  • If available, take a replacement part from the
    replacement container, or wait (suspend)
  • Install the replacement part

15
Repairman Object
  • Check if there are parts in the damaged parts
    container
  • If available, take a damaged part and repair it
  • Place the repaired part in the proper container
  • If there are no damaged parts available, carry
    out some background task
  • Check for pending background job to complete
  • If there is an interruption, carry out interrupt
    service routine

16
Java Code for Repairman Process
delay(job_per) // execute
background job pending_job false
if (int_level() REPAIR) // job
interrupted? rem_time
get_remain_t() Intrep.out.println(get_
name() " interrupted at "
get_clock()) clear_int()
// clear interrupts pending_job
true // end if
17
CarWash System With Interrupts
  • Multi-server system
  • Priority queue for customer objects
  • Simple queue for available servers
  • Priority queue for bust servers
  • A server can be interrupted by a customer

18
Interrupts in Carwash Model
  • A customer can interrupt a server that is
    servicing a lower priority customer
  • When there are no available servers, an arriving
    customer will interrupt the server with the
    lowest priority customer that started most
    recently
  • There are two queues for Server objects
    available and busy_queue

19
Car Process
  • An arriving car joins the car priority queue
  • If there are no servers available
  • Examine the busy server queue, try to get the
    lowest priority server that started service most
    recently
  • If a server is found with a lower priority than
    current car, interrupt the server
  • Suspend itself to wait for service

20
Java Code in Car Process
// there are no available servers // interrupt a
busy server with lowest priority machine
(Server) Carwash.busy_queue.pllast(mtype) if
(machine ! null) Carwash.out.println(get_
name() " interrupting "
machine.get_name()) machine.p_interrupt(1)
// interrupt server else
Carwash.out.println(get_name() "
no server with lower priority available ")
21
Server Process
  • If car (priority) queue is empty, suspend
  • If queue not empty, get the next car with the
    highest priority from the priority queue
  • Service the car
  • If interrupted
  • store the remaining time of current service
  • get the next car with higher priority from the
    car queue

22
Java Code in Server Process
// Was this service interrupted? if
(int_level() 1) // interrupt level 1
// return customer object to customer queue
Carwash.car_queue.pback (currentCustomer)
rem_time get_remain_t() // remaining
service time currentCustomer.change_servp(
rem_time) currentCustomer.set_pend()
// pending flag clear_int()
23
Controller Interrupts Gate
  • // interrupt gate opening and get remaining time
    left
  • cout ltlt "Controller interrupting gate at "
  • ltlt get_clock() ltlt endl
  • gt_rem gate_obj-gtp_interrupt(INT_CONT) //
    interrupt Gate

24
Gate Checking for Interrupt
  • // Check if interrupted by the controller
  • // because of excessive waiting to communicate
  • if (int_level() INT_CONT)
  • cout ltlt "Gate interrupted, resetting
    at "
  • ltlt get_clock() ltlt endl
  • clear_int()
Write a Comment
User Comments (0)
About PowerShow.com