Loading the lesson...
In the print dialog, choose "Save as PDF" as the destination.
Operating Systems 1 - Lab
Why shared data needs protecting, the four ways C# protects it, and the classic problem where the protection itself hangs.
| Term | What it means |
|---|---|
| Dual / Quad core | a machine with two or four physical processors |
| Multi-processing | one processor containing several arithmetic and logic units |
| Multi-tasking | one processor switching between processes by a context switch |
7, 5 and 3 do not indicate core countGHz3.2 GHz CPU executes 3.2 billion cycles every secondTickets variable holds the number left to sellThread 1 Thread 2
1. If (Tickets > 0)
2a. Register = Tickets
2b. Decrement register
2c. Tickets = register
3. Print "Tickets"
1. If (Tickets > 0)
2a. Register = Tickets
2b. Decrement register
2c. Tickets = register
3. Print "Tickets"lock, Mutex, Monitor and Semaphore| Mechanism | How it is acquired and released |
|---|---|
lock | exclusive locking, the language keyword |
Mutex | also exclusive but slower, via WaitOne and ReleaseMutex |
Monitor | exclusive as well, via Monitor.Enter and Monitor.Exit |
1 makes it a binary semaphore, behaving like a lock or mutex1 makes it a general semaphore, letting several through togetherPhilosopher takes the right fork
Waits for the left fork
The neighbour already holds it
Nobody can ever eat
lock, Mutex, Monitor and Semaphore are the four ways to enforce itMahmoud Abas|Operating System 1 Week06 Lab