thumbnail

Monitory

Quiz by
Hralyb
Rate:
Last updated: May 14, 2025
You have not attempted this quiz yet.
First submittedMay 14, 2025
Times taken11
Average score71.4%
Report this quizReport
30:00
Enter answer here
0
 / 63 guessed
The quiz is paused. You have remaining.
Scoring
You scored / = %
This beats or equals % of test takers also scored 100%
The average score is
Your high score is
Your fastest time is
Keep scrolling down for answers and more stats ...
Hint
Answer
notify deklarace
struct Monitor{
 
semaphor mutex, condition;
 
int condCount;
 
}
notify inicializace
void initS(struct Monitor *s){
 
init(s->mutex, 1);
 
init(s->condition, 0);
 
s->condCount = 0;
 
}
enter
void enter(struct Monitor *s){
 
lock(s->mutex);
 
}
wait
void wait(struct Monitor *s){
 
s->condCount++;
 
unlock(s->mutex);
 
lock(s->condition);
 
lock(s->mutex);
 
}
notify
void notify(struct Monitor *s){
 
if(s->condCount > 0){
 
s->condCount--;
 
unlock(s->condition);
 
}
 
}
leave
void leave(struct Monitor *s){
 
unlock(s->mutex);
 
}
signal deklarace
struct Monitor{
 
semaphore mutex, condition, priority;
 
int condCount, prioCount;
 
}
signal inicializace
void Init(struct Monitor *s){
Hint
Answer
 
init(s->mutex, 1);
 
init(s->condition, 0);
 
init(s->priority, 0);
 
s->condCount = s->prioCount = 0;
 
}
monitorEnter
void monitorEnter(struct Monitor *s){
 
lock(s->mutex);
 
}
condWait
void condWait(struct Monitor *s){
 
s->condCount++;
 
if(s->prioCount > 0)
 
unlock(s->priority)
 
else
 
unlock(s->mutex);
 
lock(s->condition);
 
s->condCount--;
 
}
condSignal
void condSignal(struct Monitor *s){
 
if(s->condCount > 0){
 
s->prioCount++;
 
unlock(s->condition);
 
lock(s->priority);
 
s->prioCount--;
 
}
 
}
monitorExit
void monitorExit(struct Monitor *s){
 
if(s->prioCount > 0)
 
unlock(s->priority);
 
else
 
unlock(s->mutex);
 
}
Save Your Stats
Your Next Quiz
Can you name the countries with the highest GDP per capita?
A harder version of the countries of the world quiz.
Uh oh, my literary character is happy, but that’s such a boring word! Help me by clicking only words that mean “happy”.
Drag the flag onto the correct country. Careful, though! One wrong move and the game ends.
Comments
No comments yet