Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Question about Unix programming

    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
    Cool

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Netherlands
    Posts
    217
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New Coder
    Join Date
    Sep 2002
    Location
    Up North (UK)
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hi, Just some help needed

    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
    Attached Files Attached Files

  • #5
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Difference between thread in unix & linux

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •