Hi,
I am trying to write a few system call for message passing
the saveMsg system call takes parameters of message ID, length and content
so Im trying to use a struct Msg that contain long ID, long length, and char msg
so where should I save the data for all of the messages I saved so that the retrieveMsg system call can get the content of the message by ID?
thanks
C question: message passing
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: C question: message passing
Do not switch browser tabs or windows, do not grab a book. Name at least 6 data structures. List their operations and how well they perform. Explain for each unique operation why it is relevant for your task or not.
Did that solve your problem? (If you could not answer those questions at all or had to peek, please go read the forum rules)
Did that solve your problem? (If you could not answer those questions at all or had to peek, please go read the forum rules)
Re: C question: message passing
Since this is an OS development forum and you mentioned system calls; I assume your question is non-trivial. Can you state more on your requirement?
For example, at what level the message passing interface works?
Within an multi-threaded application or inter-process communication?
Support message priority?
Should it affect scheduling?
Does it enforce a fixed size payload or is it dynamic, and have a certain size limit?
It can actually get quite complicated when you integrate with scheduler and memory manager; on the other hand, it is very simple to implement a plain message queue as a library function.
For example, at what level the message passing interface works?
Within an multi-threaded application or inter-process communication?
Support message priority?
Should it affect scheduling?
Does it enforce a fixed size payload or is it dynamic, and have a certain size limit?
It can actually get quite complicated when you integrate with scheduler and memory manager; on the other hand, it is very simple to implement a plain message queue as a library function.
Re: C question: message passing
Build a linked list of saved messages, sorted numerically if necessary. Allocate memory for them one at a time, ten at a time, or whatever seems reasonable (assuming you have a memory manager, which I think should be one of the first things you write).conlonloi wrote:Hi,
I am trying to write a few system call for message passing
the saveMsg system call takes parameters of message ID, length and content
so Im trying to use a struct Msg that contain long ID, long length, and char msg
so where should I save the data for all of the messages I saved so that the retrieveMsg system call can get the content of the message by ID?
thanks
Re: C question: message passing
I don't know what exactly you are coding, but if you need brief intro about messages check this:conlonloi wrote:Hi,
I am trying to write a few system call for message passing
the saveMsg system call takes parameters of message ID, length and content
so Im trying to use a struct Msg that contain long ID, long length, and char msg
so where should I save the data for all of the messages I saved so that the retrieveMsg system call can get the content of the message by ID?
thanks
http://wiki.osdev.org/Message_Passing
and if you need an in deep study check out these:
"User-Level Interprocess Communication for Shared Memory Multiprocessors (1991)"
http://citeseer.ist.psu.edu/viewdoc/sum ... .1.17.1382
it is old but frequently cited by many OS developers
here is another one:
http://www.barrelfish.org/barrelfish_sosp09.pdf
Now, about this one, it is sponsored by Microsoft, and developed by a lot of gurus, but when they released the OS code it was slow , and (i think) it is because they don't use shared memory but pass large messages.
You could also search for keywords adding 'pdf' to your query and it will find a lot of messaging implementations of other people, some of them state of the art.