10/01/08 Operating System Notes

Operating System Notes

Readers and Writers Problem:
Policy decisions:
Readers reading the resource. If a writer comes followed by a reader, whether we let the reader in first or the writer in first. If we let the readers in first, we probably have a situation of writers’ starvation. We do not preempt the resource.
Set the amount of readers that can get in front of the writers.
//————————————————-
typedef int semaphore;
semaphore protectCount = 1; //mutex
semaphore protectDB = 1; //mutex
int rc = 0;

void beforeWriting() {
P(protectDB);
}

void afterWriting() {
V(protectDB);
}

void beforeReading() {
P(portectCount);
if(++rc == 1) {
P(protectDB);
}
V(protectCount);
}

void afterReading() {
P(portectCount);
if(–rc == 0) {
V(protectDB);
}
V(protectCount);
}
//————————————————-

Lock the shared resources.
Do not access the value of semaphores.

Memory Management:

Binding:

  • If a program has a line: int x; When is the address of x decided.
  • At compile time
  • At load time
  • At run time
Advertisement

There are no comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.