The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]




Версия для распечатки Пред. тема | След. тема
Новые ответы [ Отслеживать ]
Synchronization among Threads., !*! nace, 26-Дек-03, 00:21  [смотреть все]
Если кто нибудь может помочь с этой программой, сдать нужно в универ.
domain com  с меня.
плюс еще и хостинг дам на год.
braslavsky@hotmail.com


это задание:

Synchronization among Threads.

Abstract

The overall scenario of this assignment is implementing a producer/consumer paradigm. In this simulation the producers will generate products (strings) and add them to a bounded buffer. The consumer will simply pull those strings, store them in a database, and after the last one is stored, present them on screen. The number of producers and the amount of strings will be given in the command line.

Bounded Buffer

A bounded buffer is a data structure (similar to a Queue, FIFO order) that supports the following operations.

·        Bounded_Buffer (int size) – (constructor) create a new bounded buffer with size places to store objects.

·        void insert (char * s) – insert a new object into the bounded buffer.

·        char * remove ( ) - Remove the first object from the bounded buffer and return it to the user.

You must implement a thread safe bounded buffer. In order to do so you will be supplied with a binary semaphore (mutex) and create a counting semaphore with two binary semaphores as studied in class. The implementation of a 'bounded buffer' synchronization mechanism, with two counting semaphores and one binary semaphore was presented in class.

For more details consult your course book or material learned in class.

Producer

The Producer has a simple job. It receives at least two parameters (you might need more than two):

1.     An integer - ID

2.     Amount of strings- numOfStrings

Then on creation it follows this algorithm:

For (i=0; i<numOfStrings; i++)

{

          Produce a string.

          Add new string to the bounded buffer.

}

Produce a 'finished' string.

Add the 'finished' string to the bounded buffer.

return 0;

The strings the producer creates are constructed as follow:

·        'product' strings the producer creates:

                        Producer j in iteration i creates the string: "producer j produced product number i"

·        'finished' string:

                        Producer j: "producer j finished"

Consumer

In this assignment their will be only one consumer. The consumer holds a Data Base (array of strings) in which it stores the received strings.  The consumer will act as follow:

While (there exist a live producer)

{

          Receive a string from the buffer.

          Add the string to the DataBase.

}


  • Synchronization among Threads., !*! asso, 06:19 , 26-Дек-03 (1)
    В glibc-common есть пример producer-comsumer, называется ex2.c - это то что тебе нужно.  Если его у тебя нет установленного, то поищи гуглем, находится на ура.  Адаптировать его под твою задачу - плевое дело.  Меня не проси, я сам (экс)преподаватель ;)
  • Synchronization among Threads., !*! nace, 22:21 , 30-Дек-03 (2)
    со мной также можно связатся по ICQ 130440733
    если кто может, помогите, очень срочно нужно сдать эту работу.
    как и обещал с меня домейн с хостингом.
    заранее благодарен за помощь!

    всех с наступающим новым годом!




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру