0

What would be a best and simple way of storing incoming message from different processes in an array in C? I was thinking to have an array MQ but also need to store message sequence numbers and process ids for each incoming message. Thanks.

1
  • Is the question concerning how to store the data or how to do it threadsafe? Commented Mar 14, 2011 at 2:50

1 Answer 1

3

It sounds like you want to have an array of structures that contain the various elements that you want to store, e.g.

struct MessageInfo {
  int message_id;
  pid_t incoming_pid;
  char message_data[MAX_MESSAGE_LEN];
};

struct MessageInfo message_queue[MAX_QUEUE_LEN];
Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, depends if he is asking about the actually structure or about thread safety part.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.