How to create a stream in unix?

How to create a thread in Unix programming?

What is the difference between forking and threading?

Is slicing more useful than forking?

+4
source share
4 answers

Commonly used POSIX threads or some other technology wrapped in its API. The fork starts new processes, threading breaks the existing process into pieces. Streams of results in an overall global state that may or may not be useful given the circumstances.

+4
source
  • pthread_create()

  • Forking creates two processes, each of which has a separate control flow. Creating a thread creates an additional control flow within a single process.

  • No - it’s usually harder to get streaming applications than right to get individual processes. And quite a large supply.

+3
source

Forking creates a copy of the current process, while threads run in the same process and are usually used to calculate something in the background, so the application does not seem to be frozen.

Regarding the usefulness of threads versus forking, I would go with threads if you don't have a specific need for a second process.

Regarding thread creation, I would recommend using the pthreads library. It will work on any UNIX operating system (Linux, BSD, Mac OS X), but is relatively low. If you want something higher level, check out QThread from QT.

+2
source

1. In the Fork core, all resources and memory are allocated.

2. The process is divided in the thread and shared the process memory

0
source

All Articles