Question

In: Computer Science

Process & Thread Management differences in Windows10, Linux, and Andriod.

Process & Thread Management differences in Windows10, Linux, and Andriod.

Solutions

Expert Solution

Process & Thread Management differences

Windows 10 Linux Android
A process is a software program that is currently running in Windows. Every process has an ID, a number that identifies it. A thread is an object that identifies which part of the program is running. Each thread has an ID, a number that identifies it.

Threads in Linux are nothing but a flow of execution of the process. A process containing multiple execution flows is known as multi-threaded process.

By default, all components of the same application run in the same process and most applications should not change this. However, if you find that you need to control which process a certain component belongs to, you can do so in the manifest file.

A process may have more than one thread. The purpose of a thread is to allocate processor time. On a machine with one processor, more than one thread can be allocated, but only one thread can run at a time. Each thread only runs a short time and then the execution is passed on to the next thread, giving the user the illusion that more than one thing is happening at once. On a machine with more than one processor, true multi-threading can take place. If an application has multiple threads, the threads can run simultaneously on different processors.

For a non multi-threaded process there is only execution flow that is the main execution flow and hence it is also known as single threaded process. For Linux kernel , there is no concept of thread. Each thread is viewed by kernel as a separate process but these processes are somewhat different from other normal processes. I will explain the difference in following paragraphs.

When an application is launched, the system creates a thread of execution for the application, called "main." This thread is very important because it is in charge of dispatching events to the appropriate user interface widgets, including drawing events. It is also almost always the thread in which your application interacts with components from the Android UI toolkit (components from the android.widget and android.view packages). As such, the main thread is also sometimes called the UI thread. However, under special circumstances, an app's main thread might not be its UI thread; for more information, see Thread annotations.

The Windows kernel-mode process and thread manager handles the execution of all threads in a process. Whether you have one processor or more, great care must be taken in driver programming to make sure that all threads of your process are designed so that no matter what order the threads are handled, your driver will operate properly.

Threads are often mixed with the term Light Weight Processes or LWPs. The reason dates back to those times when Linux supported threads at user level only. This means that even a multi-threaded application was viewed by kernel as a single process only. This posed big challenges for the library that managed these user level threads because it had to take care of cases that a thread execution did not hinder if any other thread issued a blocking call.

The manifest entry for each type of component element—<activity>, <service>, <receiver>, and <provider>—supports an android:process attribute that can specify a process in which that component should run. You can set this attribute so that each component runs in its own process or so that some components share a process while others do not. You can also set android:process so that components of different applications run in the same process—provided that the applications share the same Linux user ID and are signed with the same certificates.

If threads from different processes attempt to use the same resource at the same time, problems can occur. Windows provides several techniques to avoid this problem. The technique of making sure that threads from different processes do not touch the same resource is called synchronization. For more information about synchronization, see Synchronization Techniques.

Later on the implementation changed and processes were attached to each thread so that kernel can take care of them. But, as discussed earlier, Linux kernel does not see them as threads, each thread is viewed as a process inside kernel. These processes are known as light weight processes.

The system does not create a separate thread for each instance of a component. All components that run in the same process are instantiated in the UI thread, and system calls to each component are dispatched from that thread. Consequently, methods that respond to system callbacks (such as onKeyDown() to report user actions or a lifecycle callback method) always run in the UI thread of the process.

Routines that provide a direct interface to the process and thread manager are usually prefixed with the letters "Ps"; for example, PsCreateSystemThread. For a list of kernel DDIs, see Windows kernel.

The main difference between a light weight process (LWP) and a normal process is that LWPs share same address space and other resources like open files etc. As some resources are shared so these processes are considered to be light weight as compared to other normal processes and hence the name light weight processes.

Android might decide to shut down a process at some point, when resources are required by other processes that are more immediately serving the user. Application components running in the process that's killed are consequently destroyed. A process is started again for those components when there's again work for them to do.

Additionally, the Android UI toolkit is not thread-safe. So, you must not manipulate your UI from a worker thread—you must do all manipulation to your user interface from the UI thread. Thus, there are simply two rules to Android's single thread model:

  1. Do not block the UI thread
  2. Do not access the Android UI toolkit from outside the UI thread

Related Solutions

Differences Between Linux and Windows Operating Systems Two key differences between a Linux operating system and...
Differences Between Linux and Windows Operating Systems Two key differences between a Linux operating system and a Windows operating system are the concepts of “mounting” and “drive” letters. Provide an example for each. Why is it important to plan disk partitioning before installing Linux? Discuss the advantages of disk partitioning. Also discuss what logical volume management (LVM) is and why or why you might use it.
Explain five differences between a fork and thread
Explain five differences between a fork and thread
What is a program? What is a process? What is a thread?
What is a program? What is a process? What is a thread? Explain the differences/similarities in details between them.
Thread: DQ1: Discuss the decision-making process in the textbook.
Thread: DQ1: Discuss the decision-making process in the textbook.
Submit a thread of at least 400 words on an accounting estimate made by management and...
Submit a thread of at least 400 words on an accounting estimate made by management and how a fraud could be a risk in making this estimate.
Does the following describe a "thread" or a "process"? Fill in the blank. Considered a heavyweight...
Does the following describe a "thread" or a "process"? Fill in the blank. Considered a heavyweight operation Does the following describe a "thread" or a "process"? Fill in the blank. Context switching is less expensive
Please explain how to do following in Linux How to list process How to grep process...
Please explain how to do following in Linux How to list process How to grep process how to kill a process how to know pid suppose proccess is down how to check it up and bring it up ?? please write the commands and execute and explain the process
Process Management is about continuous improvement. Discuss similarities and differences between the Deming Cycle Methodology and...
Process Management is about continuous improvement. Discuss similarities and differences between the Deming Cycle Methodology and the Kaizen approach to process improvement.    COURSE: QUALITY MANAGEMENT CONTROL
discuss the similarities and differences between nursing process and case management when caring for chronically ill...
discuss the similarities and differences between nursing process and case management when caring for chronically ill clients and those who have acute/chronic trajectory. Also, how evidence-based practice used to support their care. Finally students will be writing about quality of life and health promotion. This is an essential area of learning as you will need to understand the differences in dealing with chronic illness versus acute and the needed refinement to their practice to assist others in achieving quality and...
B. Discussion Thread: "Digital Rights Management" Some people argue that digital rights management violates the public’s...
B. Discussion Thread: "Digital Rights Management" Some people argue that digital rights management violates the public’s right to fair uses. Should people or companies that create intellectual property have the right to offer it for sale (or license) in a form protected by their choice of digital rights management technology (assuming the restrictions are clear to potential customers)? Should people have a legal right to develop, sell, buy and use devices and software to remove digital rights management restrictions for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT