what is the difference between fork and thread ?
and parent and child process in fork system call?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / nanda
for() creates a new process which copy of parent only PID
is different.thread create within process except stack it
shares memory
example:
global variable seterrno is shared by multiple threads
Is This Answer Correct ? | 13 Yes | 12 No |
Answer / venkatamahalakshmaiah
what an answer Nanda..u shuld be kept in a museum..
Is This Answer Correct ? | 7 Yes | 13 No |
Tell me command which is use for create quota database in Linux.
What are the main differences between RHEL4 & RHEL5?
rpm package installation error in centos 6.4 [root@localhost packages6.4]# rpm -ivh nfs-utils-1.2.3-36.el6.i686.rpm warning: nfs-utils-1.2.3-36.el6.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY error: Failed dependencies: keyutils >= 1.4-4 is needed by nfs-utils-1:1.2.3-36.el6.i686 libevent is needed by nfs-utils-1:1.2.3-36.el6.i686 libevent-1.4.so.2 is needed by nfs-utils-1:1.2.3-36.el6.i686 libgssglue is needed by nfs-utils-1:1.2.3-36.el6.i686 libgssglue.so.1 is needed by nfs-utils-1:1.2.3-36.el6.i686 libgssglue.so.1(libgssapi_CITI_2) is needed by nfs-utils-1:1.2.3-36.el6.i686 libnfsidmap.so.0 is needed by nfs-utils-1:1.2.3-36.el6.i686 libtirpc is needed by nfs-utils-1:1.2.3-36.el6.i686 libtirpc.so.1 is needed by nfs-utils-1:1.2.3-36.el6.i686 nfs-utils-lib >= 1.1.0-3 is needed by nfs-utils-1:1.2.3-36.el6.i686 rpcbind is needed by nfs-utils-1:1.2.3-36.el6.i686
What is the complete name of the default configuration file for LILO?
How to sort a file of size 2N bytes, if I have N bytes of memory?
Where is standard output usually directed?
why /etc/shadow file do not have any permission ?
why you are using nis server
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.
what is difference between TFTP abd FTP?
there are many IPC mechanisms available in Linux ? Which one is best to use and when ?
What is the other method of installing Linux O.S other than Text, GUI mode? Why we prefer that for installation of Linux in Real time?