Theme and process

What is the best definition of flow and which process? If I call a function, how do I know that the thread is calling it or the process (or I don’t understand it ?!). This is in a multi-core system (quadcore).

+4
multithreading process
Dec 05 '08 at 18:03
source share
5 answers

One thing to add: how a multi-core processor handles this. Think of a thread as sequentially executing your code.

A core in a CPU can only execute one thread at a time. Therefore, if this thread is blocked because the program is waiting for the I / O operation to complete, the process is blocked (very simplified example: Word does not respond). Multithreading allows us to execute multiple codes simultaneously. “Same time” is a bit of a lie, since only one thread can actually be executed in the kernel at the same time, but the processor gives a small chunk of time for each thread, so it looks like all these threads are running at the same time. A good example here is spell checking in Word.

If you have multiple cores, the difference is that in the N-Core CPU you can simultaneously execute N threads. To simplify a lot, it doesn’t matter which process the threads belong to. Just to make it even bigger, you expect N times to increase productivity.: - D

+4
Dec 05 '08 at 19:24
source share

From http://wiki.answers.com/Q/What_is_the_difference_between_a_computer_process_and_thread :

One process can have several threads that exchange global data and address space with other threads working in the same process, and therefore can easily work with the same data set. Processes do not exchange address space, and another mechanism must be used to exchange data.

If we consider the launch of a word processing program as a process, the automatic saving and spell checking functions that occur in the background are different threads of this process that all work on the same data set (your document).

+6
Dec 05 '08 at 18:08
source share

In every modern OS that I know of, everything works in a thread that runs in the process. The OS can track multiple processes, and each process can accept an arbitrary number of threads. Thus, all code is executed in the thread and inside the process (since the thread is executed in the process).

The main difference between the two is that each process has its own virtual address space. Individual processes do not have access to each other's data, files, or anything else, and essentially do not know that other processes exist.

On the other hand, each thread in the process has the same address space, and therefore all threads can check or change each other's data, call the same functions and everything else.

Often (but not always) cases when one program consists of one process and several threads.

+2
Dec 05 '08 at 18:31
source share

A process consists of one or more threads (default for most environments). However, a process may create additional threads.

As in the previous answer, each process has its own memory space (each can have a pointer to 0x12345, and this memory location has different values ​​for each process), while all threads of the process actually point to the exact same memory location, since all of them are in the same memory space.

When calling a function, it almost always calls the same thread as the caller. There are exceptions in Objective-C (performSelectorOnMainThread), and may be for other languages, but such functionality is needed only in special cases.

+1
Dec 05 '08 at 18:35
source share

From the user's point of view, the main difference is that threads share memory with each other, but processes do not. This means that you can easily exchange data between threads, while processes require some kind of OS call for this.

Some people call this a useful stream, but data exchange between several control flows is fraught with danger, so it can be argued that the processes lead to more reliable code.

There is a lot more, especially if you are an OS person.

+1
Dec 05 '08 at 18:50
source share



All Articles