Thread / Process Comparison on Linux / Windows

I have experience using threads and processes on Windows.

Can someone explain if it is possible to display threads and processes on Windows in Linux?

Does that mean threads in windows == themes in linux? → Does it make sense? Process on Windows == Process on Linus? → Does it make sense?

If so, I have CreateThread () and CreateProcess () calls on Windows, what are the equivalent calls on Linux?

I read a few posts in SO, but most of them did not clear my doubts. So thought to start a new recording.

It would be nice if I get some explanation with some simple examples (C programming).

+5
source share
1 answer

, Linux , -, .

 int rv = fork(); 
 // new process was spawned here. The following code is executed 
 // by both processes.
 if(rv == 0)
 {
     // we are in the child process
 }
 else
 {
     // we are in the parent
 }

rv 0 pid . , .:)

, exec :

 int rv = fork(); 
 // new process was spawned here. The following code is executed 
 // by both processes.
 if(rv == 0)
 {
     execl("/bin/ls", "ls", NULL); // start the ls process
 }
 else
 {
     // we are in the parent
 }

/bin/ls, .

: http://flinflon.brandonu.ca/dueck/2001/62306/Processes/Unix%20Examples.htm

, fork execl . , , execl, , , .

+6

All Articles