BACI Programming: Concurrency and Producer-Consumer Model at University of Central Florida, Study Guides, Projects, Research of Operating Systems

An overview of the baci programming language, a simplified version of c++ used for concurrency programming at university of central florida. It covers the basics of writing and compiling baci programs, using semaphores, and the producer-consumer model. The document also includes instructions for installing baci and examples of producer and consumer code, as well as test cases and submission instructions.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 02/25/2010

koofers-user-4gc
koofers-user-4gc 🇺🇸

10 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Project 5
Project 5
Concurrency Programming
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download BACI Programming: Concurrency and Producer-Consumer Model at University of Central Florida and more Study Guides, Projects, Research Operating Systems in PDF only on Docsity!

Project 5Project 5

Concurrency Programming

Overview^ 

Learning concurrency programming



No relationship with previous projects



Based on BACI, a simplified C++ language

Simple Sample

void print_number(int i){ cout<<i<<endl; } main(){ cobegin { University of Central Florida { print_number(1); print_number(2); print_number(3); } }

Semaphore^ 

Semaphore

semaphore s = 17;

p(s); - v(s); 

Binary semaphore



Binary semaphore

binarysem b = 0;

p(b); - v(b);

Producer and Consumer^ 

A bounded buffer

Size of 20 

Producer put multiple items

produce one by one, once an item has been produced, it is available to consumer immediatelyavailable to consumer immediately 

Consumer take 1 item a time



If buffer is full, producer wait



If buffer is empty, consumer wait



First In, First Out



You will need to test 1 producer, multiple consumers

Producer and Consumer 

void producer(int NullLoop, int NumberOfItems){ ……for (i=0;i<NullLoop;i++) {} …… // produce items one by one// for every item produced, print it out// cout << "producer enter a new item " << total << ", value: " << value << endl; …. }  void consumer(int NullLoop, int ConsumerID){ ……for (i=0;i<NullLoop;i++) {}cout << "consumer " << ConsumerID << " remove an item " << value << endl;…… }

Submission^ 

Submit on olympus

If you work on your own computer, upload it to olympus

You will need new Makefile - cp /export/home/e/emontagn/project/Makefile3 Makefile - make submitcc 

Due date:

Nov 26 (Monday) midnight