Solve and write the specified synchronization problem using pthread & C.

Task/Problem Description:

Write a multithreaded car park simulator program in C as follows:

1. Five drive-in threads (simulating in-valets) should randomly move cars into the car park

2. Two drive-out threads (simulating out-valets) should randomly take cars out of the car park

3. A monitor thread should periodically print out a map of the car park showing the parking slots and the identities of the currently parked cars in the occupied slots.

You can do this by using one monitoring thread, 5 producer threads (simulating arrivals) and 2 consumer threads (simulating departures) with a bounded buffer (simulating the car park) of integers (simulating cars and car identities). The capacity of the car park (the buffer size) should be supplied to your program as a command line parameter.


• Use Ptread Locks for both synchronization and mutual exclusion.

• Implement mutual exclusion where appropriate.

• Do not remove cars from an empty car park.

• Do not add cars to a full car park.

• Avoid busy-waiting, starvation and deadlocks.

• Each producer/consumer thread must pause for a random period (up to 1s) between parking and/or removing a car.

• Each producer/consumer thread must pause for a random period (up to 0.2s) in its critical section.

• The monitor thread should periodically print out the current contents of the car park.

• Use pthread_barrier_init and pthread_barrier_wait to ensure that all producer and consumer threads begin producing/consuming at the same time.

• Your simulator shall continue working until it is interrupted from the keyboard by control-c.

The output from the monitor thread must clearly show that your simulator is working as specified above. Study the output of your program to check it is operating properly, i.e. cars are continuously parking and leaving, consistently, no deadlock, no starvation, and no busy-waiting.

What to turn in:

1. Your program design document in .pdf form.

2. The fully documented, commented and working C program, in .c file(s).

3. A meaningful sample of your program’s output in .pdf form.

4. A statement report of your observations and comments about your program output in .pdf.

5. All the above in one .zip file, that also includes your cover page and the executable file(s)

Tags: C Programming, C++ Programming
Bid on this Job!


Here are some random jobs:

ERD with Entities

I need an ERD to be drawn. I will provide details in the chat....Read Full Description

Creating an annealer/genetic algorithm to determine the fastest pitstop strategy from python

You will also need the following librariesinstalled through pip to give you access tosome of the algorithms for this project:simanneal,deap,sklearnYour task is to create a simulator as described in the document file that i have attached in [login to view URL] ...Read Full Description

Set up and omegle chatbot

I need to set up an omegle bot that can link the discord server I am trying to grow. I tried myself but know next to nothing regarding coding, programming, or whatever a git repository is. Don't know how hard it is to do, so price is negotiable.Edit: woul...Read Full Description

Cherche pro de wamp, mysql et apache

Bonjour,Je suis en train de mettre en place des sites web.Et j'aurai besoin de configurer appache etc...Et surtout mes sites sont sur unix (NAS).Merci...Read Full Description

auction buying api

Hi, PLEASE DON'T BID OR CHAT BEFORE YOU READ AND LEARN WHAT I WANTLooking to have my personal website to sell items from other sites,my customer will signup on my website, they pay deposit manually to me and i will let them to use my ID account to buy ite...Read Full Description

Long term python developer good at document extraction

Need a long term python developer who is good at document extraction and algorithms. The job is to improve my current document extraction codebase and implement changes in database and front end. Preferably someone whose timezone is close to Sydney. Technologi...Read Full Description

expert needed scss for angular 6 project and should know angular material should work either on team viewer or anydesk

expert needed css/ scss for angular 6 project and should know angular material . should implement wire frame and wont take much time ....Read Full Description

We need react.js developers for one week work

We need a react developers to help us finish a project. We have many small tasks needs to be done as fast as you can.Tech stack: react, redux, scss...Read Full Description


© 2005 - 2018
1304537 contracts/jobs/projects currently available in our database.