OpenCProducerConsumerEx is a hybrid application that depicts solution for producer consumer problem using Open C. This application uses main() as an entry point for the application. It uses libc and libpthread
Click on the following link to download the example: opencproducerconsumerex.zip
Click: browse to view the example code.
The following sections provide information about the implementation of the example.
Capabilities
The program capability is defined in: ProducerConsumer.mmp (EXE - application): CAPABILITY NONE .Implementation details of EXE
This is a simple console based application. Main thread of the application will create a thread named as Producer that will produce the item and push it on to the stack. There will be N consumers which want to consume some N(i) items from the Producer. Producer will produce N items at a time and pushes them to the stack and totally it will produce sum(N(i)) items. The consumer thread will try to pop items from the stack and each consumer will pop N(i) items from the stack. The application will create one thread for each consumer. Producer and all the consumer threads will be synchronized using a semaphore. The main thread, Producer and the consumer codes are pure C-code. the stack used by Producer and the consumer threads is Standard C++ code. Apart from these threads, there is another thread named as Observer that is created using Symbian platform API. Producer and the consumers will establish a message queue with this thread and Observer will read message from all other threads and will log them to a file wich is opened/written using Symbian APIs. Hence, this application is a hybrid application with:Standard C code -> Consumer.c , Producer.c , ProducerConsumer.c , CommanHeader.h
Standard C++ code -> Stack.cpp , Stack.h , CommanHeader.h
Symbian platform code that uses libc APIs and Observer.cpp.
The application has its own icon and can be launched from the UI both in the emulator and in the device.
API Usage
string APIs
IPC APIs (message queue and semaphore)
Threading APIs (from pthread)
console I/O APIs
File APIs of Symbian platform
Threading APIs of Symbian platform
The application is simple console based application. It has its own default icon and can be launched from the UI both in the emulator and in the device. The application can be launched by: Executing OpenCProducerConsumerEx from eshell. Clicking default icon with display text OpenCProducerConsumerEx within the install folder launcher application.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.