what is the difference between fork and thread ?
and parent and child process in fork system call?

Answer Posted / amith

fork() system call in UNIX causes creation of a new process
the new process (child process) which is an exact copy of
the calling process(parent process).return value from fork
() is used to distinguish the parent from the child; the
parent receives the child's process id, but the child
receives zero.

A thread is a stream of instructions that can be scheduled
as an independent unit.

A thread is a stream of instructions that can be scheduled
as an independent unit. It is important to understand the
difference between a thread and a process. A process
contains two kinds of information: resources that are
available to the entire process such as program
instructions, global data and working directory, and
schedulable entities, which include program counters and
stacks. A thread is an entity within a process that
consists of the schedulable part of the process.

A fork() duplicates all the threads of a process. The
problem with this is that fork() in a process where threads
work with external resources may corrupt those resources
(e.g., writing duplicate records to a file) because neither
thread may know that the fork() has occurred.

When a new perl thread is created, all the data associated
with the current thread is copied to the new thread, and is
subsequently private to that new thread! This is similar in
feel to what happens when a UNIX process forks, except that
in this case, the data is just copied to a different part
of memory within the same process rather than a real fork
taking place.

A fork() induces a parent-child relationship between two
processes. Thread creation induces a peer relationship
between all the threads of a process.

Is This Answer Correct ?    25 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the differences between FTP , NFS , SAMBA servers explain separately.

698


This question is belong to linux support. "one of my customer told to me, my application is getting slow response". how to resolve the issue. what are the steps you will follow to resolve the issue.

1456


i installed clustering packages.When i try to run it getting LUCI error...what is it..??

1944


Why is it suggested to disable journalism in ext4 filesystem?

3053


What is the difference between ext3 and ext4?

2005






What is Hard mount and soft Mount?

1356


I want to configure production interface and manage interface, how to configure both interfaces in Linux. please post the answers

1496


why /etc/shadow file do not have any permission ?

1042


How to Trouble shoot performance issue in RHEL administration ? please give to one example

1624


1. User gaves df -h and the system get hanged. why ? 2. what is the hardlink and softlink mount ? 3. why is portmape should be started ? 4. what is nologin option 5. how to restrict users from accessing nfs ? 6. what is the difference between cpio and tar 7. what are the kernel parameters ? how to find out it ? 8. why we use sysctl.conf ? 9. if we gives init1 from multiuser runlevel, will it affect other users who already logged in to the system ? 10. what will be the available space to use after configuering raid5 with 5 disks each having 5gb spce ?

2283


How to catagories tickets in RHEL, which tickets are belong to PROBLEM, INCIDENT and CHANGE management? please given to me with examples

1329


what is difference between  TFTP abd FTP?

1608


As a system admin i want to know some things what are the troubleshooting issues we are facing frequently and what are the tickets will be raised.

1075


what is the gate of ftp server in redhat linux?

1431