Operating System Fundamentals



Download 2.34 Mb.
View original pdf
Page26/66
Date06.03.2023
Size2.34 Mb.
#60834
1   ...   22   23   24   25   26   27   28   29   ...   66
OperatingSystemFundamentals
best answers from c, Lesson 2 C# Windows Forms
Why threads
Performing a quick search on the Internet or looking at most textbooks will often provide the description that a thread is a lightweight process. It is starting to appear that processes and threads are almost interchangeable terms. If you recall one from the section on the overview of an operating system, most operating systems have a responsibility of protecting one application from another application (if Internet Explorer crashes it should not cause Word to crash or lose data. As a result, having two processes communicate or share information is a bit complex due to the security. However, within a single application there is usually no such protection between threads. As a result, it is often very easy for two threads to cooperate on a common set of data. If the lack of protection between threads sounds like it is a bit risky, then you are completely correct Improperly designed applications that rely on multiple threads can result in very difficult to solve problems that only sometimes occur. With multiple threads, the scheduler is still allowed to select any thread to run that is ready and this means that if you run a multi- threaded program ten times, it might actually run ten different ways (sometimes one thread might get more time at the start. This is often why a program might work fine today, but might crash unexpectedly tomorrow. Multi-threaded programs written correctly have a great advantage but it takes the right type of programming design and testing to remove bugs. In many life critical systems such as medical equipment or avionics systems, and even high demand systems such as telephone equipment, the design team will often avoid using more than one thread to reduce unpredictability at the cost of increasing the complexity of the code.

Operating System Fundamentals
37 Inter Process Communication The term inter process communication refers to information being exchanged between two processes. Although the title of the section seems to suggest that the techniques described here are only for processes, they actually work equally for multiple threads within a single process. When two or more threads (regardless if they are in the same processor not) are trying to cooperatively work on a solution to some problem, they need some sort of mechanism to exchange information so that they can decide which part of the problem will be solved by which thread, and to ensure that they do not both try to work on a single part of the problem at the same time. There maybe other situations where one thread would like to wait for the other thread to finish first before continuing on. All of these cases require some sort of communication so that the two threads can coordinate.

Download 2.34 Mb.

Share with your friends:
1   ...   22   23   24   25   26   27   28   29   ...   66




The database is protected by copyright ©ininet.org 2024
send message

    Main page