. Synchronization and deadlocks:
(a)
Consider a data type called bank account, defined by the following:
typedef struct {
unsigned SSN;
float balance;
semaphore mutex;
} bankaccount;
Suppose we have a set of such accounts. Suppose further that a function Find Account exists that, when called with an unsigned argument, returns a pointer to the record containing an SSN (the key) equal to the argument, and NULL if no such record exists. You may assume that at most one record (bank account) exists for each unique SSN. The following procedure named Debit takes two SSNs, subtracts the specified amount (a float argument) from the first account if the balance is greater than or equal to the requested amount, and adds it to the second.
Comments
Leave a comment