What is the difference between inter process and inter thread collaboration? Why do you need kernels

Updated on technology 2024-02-25
8 answers
  1. Anonymous users2024-02-06

    Inter-process mutex: One or more program segments in a group of concurrent processes must be executed in a unit that does not allow cross-execution because they share a common resource, that is, two or more concurrent processes that share the resource are not allowed to enter the critical zone at the same time.

    Inter-process synchronization: A group of concurrent processes in an asynchronous environment cooperate with each other or wait for each other due to direct constraints on sending messages to each other, so that each process executes in a certain order.

  2. Anonymous users2024-02-05

    Pipelines: Pipes are a kind of halfDuplex mode of communication, individual processesMutually exclusive accessPipelinesData can also only flow in one direction, but full-duplex communication can be achieved through two pipes.

    Shared storage: Storage space that can be accessed by multiple processes in a mutually exclusive manner, either based on a data structure (such as an array) or based on a storage area.

    Message queues: Deliver structured messages. Each process has a message buffer queue that is quite like a mailbox. Process A communicates with process B to send messages to process A's message buffer queue.

    Semaphore: It is used to control the access of multiple processes to shared resources. It is mainly used as a means of synchronization between processes and between different threads within the same process.

    There are two types of semaphores: shaped and recorded. The shaping semaphore does not satisfy the principle of "giving the right to wait", while the recording semaphore has block and weakup primitives, which can realize the right to wait.

    Sockets

    Unlike other communication mechanisms, it can be used to:The process communication between different machines is called Zheng

    The communication between threads is not as complex as that of a process, because the thread resources of the same process are basically the same, and their communication purpose is mainly for thread synchronization and mutually exclusive access to a certain resource, so threads do not have a communication mechanism like the process communication in the process of data exchange.

  3. Anonymous users2024-02-04

    If we think of the whole road as a process, then the lanes separated by the white dotted line in the middle of the road are the threads in the process.

    These threads (lanes) share the common resources (land resources) of the process (roads).

    These threads (lanes) must depend on the process (the road), which means that the thread cannot exist independently of the process (just as the lane is meaningless without the road).

    These threads (lanes) can be executed concurrently (each lane is yours, I am mine) or synchronized with each other (some lanes are not allowed to continue or turn when the traffic light is on, and you must wait for the traffic in the other lanes to finish).

    These threads (lanes) rely on logic (traffic lights) to control the operation, and once the logic is miscontrolled (deadlocks, multiple threads competing for a unique resource at the same time), then the threads will fall into chaos and disorder.

    Note: Since the semaphore SEM used for mutual exclusion is related to all concurrent processes, it is called a public semaphore. The value of the public semaphore reflects the amount of the public resource.

    As long as the critical region is placed between p(sem) and v(sem), mutual exclusion between processes can be achieved. Just as there is only one toilet in each carriage in the train, all passengers in the carriage share this common resource: the toilet, so passengers must enter the toilet with each other, as long as the toilet is placed between P(SEM) and V(SEM), the effect of mutual exclusion can be achieved.

  4. Anonymous users2024-02-03

    Two ways to do it You know.

  5. Anonymous users2024-02-02

    There are two implementations of synchronization, synchronized, wait, and notify wait(): to put a thread in a waiting state and release the lock of the object it holds.

    sleep(): Puts a running thread to sleep, is a static method that is called to catch the InterruptedException exception.

    notify(): Wake up a thread in a waiting state, note that when this method is called, it does not exactly wake up a thread in a waiting state, but the JVM determines which thread to wake up, and not by priority.

    allnotity(): Wake up all threads that are in a waiting state.

  6. Anonymous users2024-02-01

    Answer: There are two ways to implement multithreading, which are inheriting the thread class and implementing the runnable interface.

    There are two types of synchronization implementations, which are synchronized, wait, and notify

  7. Anonymous users2024-01-31

    Threads may share resources with other threads, such as memory, files, databases, etc.

    Conflicts can occur when multiple threads read and write to the same shared resource at the same time. At this time, we need to introduce a thread "synchronization" mechanism, that is, there should be a first-come, first-served between threads, and you can't rush to rush into a mess.

    The real and literal meaning of thread synchronization is exactly the opposite. The real meaning of thread synchronization is actually "queuing": several threads are queued up to operate on shared resources one by one, rather than at the same time.

    Methods of thread synchronization.

    1) wait(): Puts a thread in a waiting state and releases the lock of the object it holds.

    2) sleep(): Puts a running thread to sleep, is a static method, this method is called to capture.

    InterruptedException exception.

    3) notify(): Wake up a thread that is waiting, note that this method is not exactly what it is when it is called.

    Wakes up a thread that waits for a state, but the JVM determines which thread to wake up, not by priority.

    4) notityall() wakes up all threads that are in a waiting state, note that instead of giving all wake-up threads a lock on an object, they are allowed to compete.

  8. Anonymous users2024-01-30

    Processes and threads are the basic units of program execution experienced by the operating system, and the system uses this basic unit to achieve the concurrency of the system to the application. The difference between a process and a thread is:

    In short, a program has at least one process and a process has at least one thread.

    That is, a process can have many threads.

    "Parallel" means that both are executed together, both from the micro and macro levels, as if two people are digging a pit with a shovel each, and after an hour, each person has a big pit.

    And "concurrency" is not executed at the same time at the micro level, but the time is divided into several segments, so that multiple processes are quickly and alternately executed, from the macro point of view, it seems that these processes are executing, which is like two people with the same shovel, take turns digging a pit, an hour later, two people each dig a smaller pit, if you want to dig two larger pits, it will take two hours.

    From the above essence, it is not difficult to see that "concurrent" execution does not fundamentally improve the execution efficiency when there are resource conflicts in multiple processes. Adopted from.

Related questions
9 answers2024-02-25

Luban software is powerful and relatively simple to use, my friend said that Glodon's software is not very stable, and the upgrade training service is also poor.

7 answers2024-02-25

Haitai is relatively fine, so it is also relatively high, containing a lot of trace elements, seaweed can not be directly practical, because it is light and difficult to swallow.

8 answers2024-02-25

The difference is not the same in the cultivation system. >>>More

6 answers2024-02-25

Light soy sauce: the color is not dark, the sauce flavor is light, the saltiness is a bit heavy, it is very delicious, and it is mainly used for seasoning; >>>More

14 answers2024-02-25

Common flooring: quality identification tiles, polished tiles, ceramic tiles, glazed tiles, bricks, bricks, special printing anti-acid resistant tiles floor tiles are very professional, remind you: > the color of the fuselage is pure to view the tile. >>>More