Ask Question

Design an algorithm for a monitor that implements an alarm clock that enables a calling program to delay itself for a specified number of time units (ticks). You may assume the existence of a real hardware clock that invokes a function tick () in your monitor at regular intervals.

+4
Answers (1)
  1. 11 December, 03:08
    0
    The algorithm a monitor that implements an alarm clock is designed below.

    Monitor alarm

    {

    Condition c;

    int current = 0;

    void delay (int ticks)

    {

    int alarms;

    alarms = current + ticks;

    while (current > alarms)

    c. wait (alarms);

    c. signal;

    }

    void tick ()

    {

    current = current + 1;

    delay. signal;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Design an algorithm for a monitor that implements an alarm clock that enables a calling program to delay itself for a specified number of ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers