Results 1 to 3 of 3
Hello,
I've got an assignment to do and it's about multiple-processor scheduling simulation by using POSIX Pthreads library functions for thread creations and synchronizations.
Can anyone recommend me a tutorial ...
- 04-07-2009 #1Just Joined!
- Join Date
- May 2007
- Posts
- 4
Looking for a tutorial on linux programming
Hello,
I've got an assignment to do and it's about multiple-processor scheduling simulation by using POSIX Pthreads library functions for thread creations and synchronizations.
Can anyone recommend me a tutorial or ebook or book that i can read to help me do the assignment?
I also need a book or tutorials on fork(),exec() etc... relating to linux as i've some questions in tutorials but i don't know what is their answers.
Some of the questions are:
when a process creates a new process, two possibilities exist in terms of execution:
a) The parent waits until some or all of its children have terminated.
b) The parent continues to execute concurrently with its children.
Which option does Linux use, possibility a) or b)?
Consider a parent process A create a child process B. In Linux OS, which process, A or B,
would be allocated with the CPU resource first?
So in what book or tutorial online can i get these answers?
- 04-09-2009 #2
I'm having difficulty finding a good tutorial for you, so I'll explain a bit about fork().
Basically, fork() works by creating a brand new process that is identical to the current one. This new process is called a "child" of the original process. You can differentiate the two because fork() will return the PID of the child in the original process, but will return 0 in the child process. Therefore, you usually see fork() used like this:
You often, but not always, see fork() combined with a call to exec(). This is a way to run a different program. Because exec() preserves the PID, the above will still work; you just have the child process execute one of the exec() calls.Code:pid_t childpid = fork(); if(childpid < 0) { /* error */ exit(1); } else if(childpid == 0) { /* child process */ /* do some stuff */ } else { /* parent process */ /* wait for the child to finish whatever it's doing */ waitpid(childpid, NULL, 0); }
I hope someone can find a good tutorial for you, but I hope that this clears up a bit about fork().Last edited by Cabhan; 04-10-2009 at 01:59 AM.
DISTRO=Arch
Registered Linux User #388732
- 04-09-2009 #3
Hello,
I don't know good tutorials either, but a good read is the "official" manual from the manufacturer of the runtime library.
The GNU C Library - GNU Project - Free Software Foundation (FSF)Debian GNU/Linux -- You know you want it.


Reply With Quote