Question

What is the data that Process and Thread will not share ?

An advance thanks goes to everybody who provide their time

No correct solution

OTHER TIPS

Separate processes do not share any data with each other.

Threads can share any heap-allocated or static data if they are running within the same process.

It depends on the context. Completely separate processes do not share any of the same memory in most cases, but in some cases child processes will share the same memory space as the parent, such as when you use fork in Unix. In older version of Windows (95,98,ME) there's a shared memory area that is shared among all processes, but mainly it's just a space for system DLLs not data.

Generally threads share heap data, but you will want to be careful deallocating memory in one thread that was allocated in another thread since some memory managers depend on the stack.

BY default no sharing of Data between processes, But using Inter-process communication techniques such as Socket , Pipes, RPC etc..you can share the data.

In operating system theory (and AFAIK this applies to operating systems such as Windows, Linux, *BSD, ...) a process is defined as a thread with its own page table, i.e. its own virtual memory space.

Anything else is OS dependant (file descriptors, sockets, etc.). In my experience, such thread properties are usually copied with standard system calls that replicate processes. Think about it, it's easier to implement and more resourceful too (less house keeping and keep non-virtual memory without touching it).

On UNIX, processes can share file descriptors with their child processes if the file descriptors are not set to close on exec (FD_CLOEXEC). Likewise, Windows supports sharing handles with child processes by setting lpSecurityAttributes->bInheritHandle to TRUE when calling CreateFile() and then setting bInheritHandles to TRUE when calling CreateProcess. Not to mention that the Microsoft C runtime _open() function accepts a _O_NOINHERIT flag.

On Linux, the clone() syscall gives you a lot of control over what the child process shares with its parent: everything from the address space (CLONE_VM) to the file descriptor table (CLONE_FILES) to the parent process ID (CLONE_PARENT) can be either shared or not shared. Of course, this functionality was added to support kernel threads.

Thread-local storage (TLS) is indexed differently for each thread in a process, but the actual memory is shared between threads.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top