Operating Systems Project: Implementing Semaphores for Producer-Consumer Problem in MINIX, Assignments of Operating Systems

A project for ecs 150 operating systems students in the fall quarter 2008. The goal is to implement user-level semaphores in minix by using the provided system calls: semup, semdown, seminit, semdestroy, and semstatus. Students are required to create a producer-consumer problem using these semaphores to synchronize access to a bounded buffer and necessary counters. The project includes initializing files, semaphores, and forking a specified number of producer and consumer processes. Hints are provided to implement these in the memory manager. Extra credit involves implementing errno codes and perror strings for more detailed error descriptions.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-p4t
koofers-user-p4t ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECS 150, Operating Systems Fall Quarter 2008
Program 4
Due Date: December 2, 2008 Points: 100
Program
1. (100 points) The MINIX kernel does not implement user-level semaphores. Your task in this project is to do so.
The semaphore system calls have the following interface:
#include <minix/semaphore.h>
int semup(int semaphorenumber);
int semdown(int semaphorenumber);
int seminit(int semaphorenumber, int value);
int semdestroy(int semaphorenumber);
int semstatus(int semaphorenumber, int *value, int *numblocked);
In all the above system calls, semaphorenumber is the number of the semaphore (0 through 9). In seminit,
the initial value of the semaphore is set to value. In semstatus, the current value of the semaphore is returned
in value, and the number of processes blocked on that semaphore is returned in numblocked.
The system call seminit creates the semaphore and returns 0 if the semaphore does not exist. The initial
value is set to value. It returns โˆ’1 if the semaphore exists. The system call semdestroy deletes the given
semaphore and returns 0. If any processes are blocked on it, though, it returns โˆ’1 and does not delete the
semaphore. All other calls return 0 on success and โˆ’1 on failure.
Please implement the producer-consumer problem to verify your semaphores work correctly. Your program
must use the semaphores to synchronize accesses to the bounded buffer (to be implemented as a file) and the
necessary counters (also kept in a file). The program will open and initialize the files, initialize the semaphores,
and then fork a specified number of producer and consumer processes which produce or consume a specified
number of items.
Hint: Implement these in the memory manager (MM), where tasks can be easily blocked and restarted. Note
that you do not need a synchronization mechanism within the kernel to protect the semaphore structures because
while the memory manager is running, no other process will run..
Extra Credit
1. (20 points) Implement appropriate errno codes and perror strings to describe errors in the above system
calls in more detail.
Write a program to demonstrate these work.
Version of November 17, 2008 at 8:27pm Page 1 of 1

Partial preview of the text

Download Operating Systems Project: Implementing Semaphores for Producer-Consumer Problem in MINIX and more Assignments Operating Systems in PDF only on Docsity!

ECS 150, Operating Systems Fall Quarter 2008

Program 4

Due Date: December 2, 2008 Points: 100

Program

  1. (100 points) The MINIX kernel does not implement user-level semaphores. Your task in this project is to do so. The semaphore system calls have the following interface:

#include <minix/semaphore.h> int semup(int semaphorenumber); int semdown(int semaphorenumber); int seminit(int semaphorenumber, int value); int semdestroy(int semaphorenumber); int semstatus(int semaphorenumber, int *value, int *numblocked);

In all the above system calls, semaphorenumber is the number of the semaphore (0 through 9). In seminit, the initial value of the semaphore is set to value. In semstatus, the current value of the semaphore is returned in value, and the number of processes blocked on that semaphore is returned in numblocked. The system call seminit creates the semaphore and returns 0 if the semaphore does not exist. The initial value is set to value. It returns โˆ’1 if the semaphore exists. The system call semdestroy deletes the given semaphore and returns 0. If any processes are blocked on it, though, it returns โˆ’1 and does not delete the semaphore. All other calls return 0 on success and โˆ’1 on failure. Please implement the producer-consumer problem to verify your semaphores work correctly. Your program must use the semaphores to synchronize accesses to the bounded buffer (to be implemented as a file) and the necessary counters (also kept in a file). The program will open and initialize the files, initialize the semaphores, and then fork a specified number of producer and consumer processes which produce or consume a specified number of items. Hint: Implement these in the memory manager (MM), where tasks can be easily blocked and restarted. Note that you do not need a synchronization mechanism within the kernel to protect the semaphore structures because while the memory manager is running, no other process will run..

Extra Credit

  1. (20 points) Implement appropriate errno codes and perror strings to describe errors in the above system calls in more detail. Write a program to demonstrate these work.

Version of November 17, 2008 at 8:27pm Page 1 of 1