Skip to content

Commit

Permalink
Merge pull request #45 from Bosslibra/main
Browse files Browse the repository at this point in the history
add scritto e soluzione 2024-06-25
  • Loading branch information
ali-benny authored Sep 14, 2024
2 parents 7396112 + 031773a commit b5506a1
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions prove/scritto/scritto-2024-06-25-soluzione.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
c1)

monitor choicesem {
queue of condition c
int value

void P(void) {
if (value == 0) {
c = new condition()
q.append(c)
c.wait()
free(c)
} else {
value--
}
}

void V(int n){
if (q.isEmpty()){
value++
} else {
if (q.len() > n) {
c = q.get(n+1)
} else {
c = q.get(1)
}
c.signal()
}
}
}

c2)
/*IDEA: mando messaggi di lunghezza inferiore per etichettare la fine di un messaggio*/

void asend (msg_t *msg, pid_t dest):
while msg.len >= 251_
lasend(<getpid(), 251, msg[:251]>, dest)
msg = msg[251:]
lasend(<getpid(), msg.len(), msg)

msg_t arecv(pid_t sender)
while True:
<pid, len, msg> = larecv(sender)
if len == 251:
msgfrom[pid] = msgfrom[pid] + msg
else:
m = msgfrom[pid] + msg
msgfrom[pid] = None
return m



g1)

P1: cpu 3, I/O 3, cpu 5, I/O 3, cpu 1, I/O 3, cpu 1
P2: cpu 3, I/O 2, cpu 1
P3: cpu 2, I/O 3, cpu 5, I/O 3, cpu 1

CPU scheduler priorità statica p1, p3, p2
I/= scheduler FIFO
Binary file added prove/scritto/scritto-2024-06-25-testo.pdf
Binary file not shown.

0 comments on commit b5506a1

Please # to comment.