Nokia N97 SDK
Example Applications Guide

commanheader.h

00001 /** 
00002  *  @file CommandHeader.h
00003  *  Part of     : Open C / ProducerConsumer
00004  *
00005  *  Description : ProducerConsumer Problem solution
00006  *  Version:   0.1
00007  *
00008  *  Copyright (c) 2007 Nokia Corporation.
00009  *  This material, including documentation and any related
00010  *  computer programs, is protected by copyright controlled by
00011  *  Nokia Corporation.
00012  *
00013  */
00014 
00015 
00016 #ifndef COMMANHEADER_H
00017 #define COMMANHEADER_H
00018 
00019 /* INCLUDE FILES */
00020 #include <semaphore.h>
00021 
00022 #define MAX_CLIENTS     10
00023 #define KPortNum                2222
00024 #define KMSGQKEY                1000
00025 #define KMAXSENDMSG     100
00026 
00027 #define IN_SET_LOOPBACK_ADDR(a) \
00028         { (a)->sin_addr.s_addr  = 0x0100007F; (a)->sin_family = AF_INET; }
00029 
00030 
00031 /* Structure used for sending details to the Producer and Consumers */
00032 typedef struct 
00033 {
00034         int   noOfItems;
00035         int   noOfConsumers;
00036         sem_t itemLock;
00037 } ThreadParam;
00038 
00039 /* Structure defining Items to be Produced */
00040 typedef struct 
00041 {
00042         int    itemNum;
00043         char   itemName[50];
00044 } ProducedItem;
00045 
00046 
00047 
00048 /**
00049  * Declaration of Producer Thread Entry Point 
00050  * @param aParam - argument to thread Entry function
00051  *
00052  * @return thread return value
00053  */
00054 void* ProducerThreadEntryPoint( void* aParam );
00055 
00056 /**
00057  * Declaration of Consumer Thread Entry Point 
00058  * @param aParam - argument to thread Entry function
00059  *
00060  * @return thread return value
00061  */
00062 void* ConsumerThreadEntryPoint( void* aParam );
00063 
00064 #ifdef __cplusplus
00065 extern "C" 
00066 {
00067 #endif
00068 /**
00069  * Declaration of Function that creats Observing Thread
00070  * @param aNoOfMsg - Number of messages
00071  *
00072  * @return Nothing
00073  */
00074 void CreateObserverThread( int aNoOfMsg );
00075 
00076 /**
00077  * Declaration of Function that Push Item onto Stack
00078  * @param aItem - Item to be pushed
00079  *
00080  * @return Nothing
00081  */
00082 void PushOntoStack( ProducedItem* aItem );
00083 
00084 /**
00085  * Declaration of Function that Pop Item from Stack
00086  * @return aItem - Item Poped
00087  */
00088 ProducedItem* PopFromStack();
00089 
00090 /**
00091  * Declaration of Function that frees up Item
00092  * @param aItem - Item to be Deleted
00093  * @return Nothing
00094  */
00095 void FreeItem(ProducedItem* aItem);
00096 
00097 #ifdef __cplusplus
00098 }
00099 #endif
00100 
00101 
00102 #endif /*COMMANHEADER_H*/
00103 
00104 /*  End of File */

© Nokia 2009

Back to top