PDA

View Full Version : Question about Unix programming



wilbasket168
09-24-2002, 06:04 PM
hey guys got some question about Unix programming. what is fork()? what does it use for? what is wait()? what is it used for? what is pipe()? what does it use for? can u give me some information coz, i have to write a simuation program which simulate a call center which a customer call in we direct the call to the call center

Bosko
09-24-2002, 10:10 PM
Please don't ask so much questions in one thread,you should buy a book if you know nothing about Unix programming,or read the man page for the specific function.
Fork spawns a copy(child) of the running process.
Wait suspends the execution of the current process until something happens (signal etc.).
I am not sure what the pipe function is,try "man pipe" or look it up in a Unix programming book.Or do you mean pipe lining?Which is redirecting the output from one program into the input of another program.

fivesidecube
09-25-2002, 10:05 AM
wilbasket168,

I agree with Bosko, you do ask a lot in one posting!

fork - duplicates the the executing process under a new process id. The new process starts executing from the instruction straight after the fork function call. Both processes are identical other than the process id changes and value returned by the fork function is zero for the new child process and the process ID of the child for the parent.

wait - waits for the process with the id given as the parameter to execute. This is used to get the returned status from the child process created via fork. A child process can not completely die until its return status has been read by its parent. If a parent fails to read this status then a zombie processes is created. This function is a blocking function and will stop the calling process until the child has returned an exit status.

pipe - creates a communications pipe between two file handles. This can be used to enable two processes to communicate. the pipe function returns two file handles that are connected, so that bytes written to one file handle are read for the second. Used with a fork function the pipe function can be used to create a communications channel between child an parent processes.

You might want to look at the popen function. This can be used in replacement of fork, pipes and wait.

Hope this helps.

monicajogi80
12-21-2006, 11:21 PM
Hi,

I need help in one of the problems I was solving
It is regarding the link system call for locking and unlocking files when 2 processes try to access the same file. there are couple of Questions with it

also, regarding the 1st question. I think ..It is "cp -p xyz.txt xyz1.txt" is the solution ....what do you think any suggestions

Please see the attached pdf for the question
Thanks
Sweety

vijayvbaskar
02-04-2009, 05:52 PM
Hi,

pthread_create() system call is used to create thread in linux.
whatever features supporting in unix will support in linux also.
but not reverse.

clone() system call is used to create child thread in linux.

which system call is used to create child thread in unix?

Thanks & Regards,
Vijay