local/message.c
///////////////////////////////////////////////////////////////////////////////
// Filename: message.c
///////////////////////////////////////////////////////////////////////////////
// Purpose: shows how to use System V IPC message queues
///////////////////////////////////////////////////////////////////////////////
// History:
// ========
//
// Date Time Name Description
// -------- -------- -------- ------------------------------------------------
// 96/03/19 02:57:14 muellerg: created
//
///////////////////////////////////////////////////////////////////////////////
// Feature test switches ///////////////////////////// Feature test switches //
/* NONE */
// System headers /////////////////////////////////////////// System headers //
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <unistd.h>
// Local headers ///////////////////////////////////////////// Local headers //
#include "../common.h"
// Macros /////////////////////////////////////////////////////////// Macros //
/* NONE */
// File scope objects /////////////////////////////////// File scope objects //
const int N = 10; // empty buffer slots at the beginning
const int produceitems = 100; // how much items to produce alltogether
// should be lower than the maximum messages
// per message queue divided by three
const int MSG_MODE = 0600; // only processes of same user have access to
// the message queue
const int consumer = 1; // type for consumer
const int producer = 2; // type for producer
// External variables, functions, and classes ///////////// External objects //
/* NONE */
// Signal catching functions ///////////////////// Signal catching functions //
/* NONE */
// Structures, unions, and class definitions /////////////////// Definitions //
// messages to be passed arount look loke this
struct message
{
long msgtype; // who sent message? producer or consumer?
// (has to be a positive long)
// needed by message queue system calls
long data; // information to transfer
};