![]() |
|
#1
|
|||
|
|||
Communication between processes in C under MinixHi All:
I'm trying to do my program on MINIX operating system,but program is in c .program that creates a mixture of compute-bound and I/O-bound processes. The numbers of each type of process should be supplied as command-line arguments. Each child process should periodically send a message (using a pipe) to the parent process, identifying itself, along with the current wall-clock time. The parent will log these messages to a text file. This text file should be created with a call to open() (i.e., don't use stdout). I/O-bound processes should repeatedly write and/or read one or more files. Compute-bound processes should sit in a tight loop, or do some other CPU-intensive operations before each message to the parent. (Extra Credit: write the child process as a separate program that outputs to stdout, and invoke it with an execl(). Use close() and dup() to setup the pipe as stdout before the execl().) i created 2 processes,connected via pipe,can write msg into buf,but getting problem with opening file,i dont know how to do that,as with time. please help me.... Thank you Jan |
|
#2
|
||||
|
||||
|
Hi Jan and welcome to GIDForums™.
It appears that your assignment wants you to use the low level file operators of open, read, write and close. If you could describe what problems that you are having useing open, I can try to help you more, but the basis of open is to pass it a filename and a flag. It will return an open file descriptor (int) upon success. CPP / C++ / C Code:
You probably would want to use the O_CREAT flag which will create the file if it does not exist or open if it does exist. You may also want to use O_APPEND if you want to write to the end of the file. Then you will probably want to use write: CPP / C++ / C Code:
to write a string, you could do something like: CPP / C++ / C Code:
As this is low-level, it will not put a new line or any other seperator for you. You need to do that yourself. Not sure if that helps, because I don't know where you are struggling... __________________
The best damn Sports Blog period. |
|
#3
|
|||
|
|||
thak for replyAs i said in prev mail,i have created parent and child processes,child is writing mesg to buffer via pipe,and parent is reading msg from child,but i want to open a file for parent to read those msgs from child.
Thanks Jan |
|
#4
|
|||
|
|||
|
Hi Janhavi,
Following is the sample program to exchange messages between 2 process and write the messages received in parent in a log file. Not sure if this is exactly what you are looking for, but will definitely give you a headstart. CPP / C++ / C Code:
|
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Urgent site review | dr_wolf | Websites Reviewed Forum | 5 | 01-Feb-2005 19:15 |
| urgent help needed :c + mysql insert | jack | C Programming Language | 1 | 13-Apr-2004 22:16 |
| urgent help:hash function | jack | C Programming Language | 5 | 05-Apr-2004 13:18 |
| urgent: problem + output filters | jack | Apache Web Server Forum | 0 | 04-Feb-2004 23:32 |
| urgent needs :apache + random function | jack | Apache Web Server Forum | 0 | 19-Jan-2004 18:41 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The