Thread and Mutex Lock Essay example

Submitted By MrMike257
Words: 362
Pages: 2

5.12
If a user-level program is given the ability to disable interrupts, then it can disable the timer interrupt and prevent context switching from taking place, thereby allowing it to use the processor without letting other processes to execute.

5.19
For a short duration, it makes more sense to use a spinlock, as it may be faster than using a mutex lock, which requires suspending, and awakening, the waiting process. For a long duration, a mutex lock is best because allows the other processing core to schedule another process while the locked process waits. If the thread may be put to sleep while holding the lock, a mutex lock is definitely better as you wouldn’t want the waiting process to be spinning while waiting for the other process to wake up.

5.23
A semaphore is initialized to the number of allowable open socket connections. When a connection is accepted, the acquire() method is called; when a connection is released, the release() method is called. If the system reaches the number of allowable socket connections, subsequent calls to acquire() will block until an existing connection is terminated and the release method is invoked.

5.38
A.
Each cross of the streets is considered as a resource, each line of cars is considered as a process.
1.Mutual exclusion: only one line of cars at a time can use the resource.
2. Hold and wait: Each line of cars is holding one resource and is waiting for the next resource.
3. No preemption: the resource cannot be released