Threads and Fork

Threads and Fork - Threads and Fork The behavior of fork()...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Threads and Fork The behavior of fork() changes depending on the flavor of threads you use. When fork() is called, threads created with pthread_create() are not duplicated except if it is the thread calling fork(). In Solaris threads created with thr_create() are duplicated in child too.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Threads and Fork Example: In Solaris one process creates 5 threads using thr_create and then calls fork() then the child will also have a copy of the 5 threads so we have a total of 10 threads In Solaris (or other UNIX flavors) one process creates 5 threads using pthread create and then calls fork() therefore the child will only get one thread that is the thread that called fork so we have a total of 6 threads Solaris has a system call fork1() that only copies the calling thread in the child process. Modern UNIX use the pthread_create semantics that only copies the calling thread.
Background image of page 2
Thread Safe and Race Condition Data structures and functions that are able to handle multiple threads are called
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

Threads and Fork - Threads and Fork The behavior of fork()...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online