Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

doubt regarding os threads

Status
Not open for further replies.
Only the calling thread.
 

Does fork()duplicate only the calling thread or all threads?
under Unix fork() creates a clone (copy) of the process and executes it concurrently with the parent. The only difference between the two processes is that fork returns the child process ID to the parent and zero to the child
 

fork is for processes not threads.
--
Amr
 

processes and threads are different things.
A process is program in execution made up of heap, stack, fixed data, code, registers, etc.
fork() creates a clone (a copy) of a process and runs the parent and child concurrently, i.e. you have two copies of the same program executing at the same time (on a single CPU machine they will time share).

When new thread is created it uses the same address space as the parent process, i.e. they share code and global variables – but have own local variables.
It is still one process but with two internal threads of control, i.e. the threads can read/write data from/to the same variable in the memory of the process.
Of course you can then fork() it and have two processes each with two threads of control.
 
  • Like
Reactions: arthur0

    arthur0

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top