C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-11-2003, 10:11 AM   #1
still a n00b
 
Jaguar's Avatar
 
Join Date: Jun 2002
Posts: 187
thread and fork()

what's different between thread and fork( ) (or vfork( )) and their usage for programming in real life?
which one could be used in which situation?
I did read several posts, but still not clear.

Thanks,
__________________
slackware 10.0; kernel 2.6.7
gcc 3.4.0; glibc 2.3.2; vim editor
migrating to freebsd 5.4
Jaguar is offline   Reply With Quote
Old 11-11-2003, 01:34 PM   #2
.
 
Join Date: Nov 2003
Posts: 293
A process is a container for execution one or more threads. A process has to have at least one execution thread.

fork() creates a process out of the old process, bringing along all of the threads. It takes a snapshot of all the variables, program counter, etc, and creates a new process with the same
program counter, data, and code set. The forked process has a new process context, outside of the old one.

A new thread remains inside the process context.
jim mcnamara is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread Prog in C language (seg fault) kumars C Programming 22 10-09-2008 01:17 PM
What happens a thread calls fork()? meili100 C++ Programming 3 09-11-2008 08:10 AM
fork a child or create a thread? zhoufanking C Programming 3 06-21-2008 03:48 AM
fork() inside a thread rpalmer C Programming 3 05-25-2007 02:29 AM
problems with fork raja9911 C Programming 2 02-03-2006 07:48 AM


All times are GMT -6. The time now is 08:03 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22