You are on page 1of 3

IT2106

Practice Exercise
Threads
Instructions:

1. Search for relative studies and/or literature regarding the process and thread concepts of the following
operating systems:
A. Linux OS

Fork () is used to create the thread from the process, and it implements the parent child
relationship between the process and the thread. The thread uses the resources used by the
process. Communication is made with signal, which has the messages. The following states
are present in the process and threads execution:
1. Running: currently executing process/threads. It includes two states which is Ready and
Executing.
2. Interruptible: suspends the execution until certain condition becomes true.
3. Uninterruptible: same as the interruptible but here it does not respond to the signals.
4. Stopped: the termination of the execution
5. Zombie: process execution is completed, but not the child process. Because the process
has not done the signal to notify about the child process

Linux has a unique implementation of threads. To the Linux kernel, there is no concept of a
thread. Linux implements all threads as standard processes. The Linux kernel does not
provide any special scheduling semantics or data structures to represent threads. Instead, a
thread is merely a process that shares certain resources with other processes.
 Multiple threads that share the same process is created by using the fork() semantics.
 A set of rules is determined to fix when and how each thread should execute.
 The scheduling of the process and threads should be done. It is done by considering
process pre-emption, time sharing, and ranking the process/threads according to their
priority.
 Priorities can be static or dynamic.
 Highest priority will be executed first

The increase in number of threads within the process does not affect the response time because
there is no maximum limit for thread creation for a process. Also, the response time increases
when there are more threads. The requests will be processed by a thread which is idle at that time
and gives quick reply. In the address space of its hosting process, it has a set of CPU registers
and stack state. In a single processor system, threading is helpful because it allows the principal
execution thread to respond to human input while supporting threads do long-running activities in
the background that do not require user participation. When considering how multithreading
works, it's vital to distinguish between parallel and concurrent processing. Parallel
multiprocessing refers to the system's ability to handle many threads at the same time. Only one
thread will be addressed at a time in concurrent processing, but the system will save time by
switching between two or more threads fast.
 The CPU time divided into epochs
 Epochs is the time runnable between all the threads.
 Every thread is given a certain time to execute. I.e., quantum period.
 When quantum period is expired, the CPU invocates or blocks the process/threads and
 sets another priority and time to execute and quantum period.

https://webeduclick.com/linux-process-and-thread-management/
https://www.informit.com/articles/article.aspx?p=370047&seqNum=3

B. Android OS
When an Android application is first launched, the runtime system automatically establishes a
single thread in which all the program's components execute. The main thread is the name
given to this thread (UI Thread). The main thread's major responsibility is to manage the user
interface in terms of event processing and interaction with views. By default, any extra
Components launched within the program will execute on the main thread too.

Any component in an application that uses the main thread to conduct a time-consuming activity
will appear to lock up the whole app until the job is done. The user will usually get an
"Application is unresponsive" (ANR) warning from the operating system. This is clearly not the
expected behavior for any software. This may be prevented in such a case by running the job on
a separate thread, enabling the main thread to continue working on other tasks without
Interruption.

 Threads in android are categorized into two: within activity fragment and without activity
fragment.
 Threads within are: asynchronized task and loaders.
 Threads are without services from other sources and intent services.
 There are main thread and background thread to handle the activities of the android.
 Main thread is responsible for all the interface related activities.
 Background threads are responsible for the activities happening in the back end for
 providing the services.

While the JVM will optimize multithreading performance automatically, the user's actual speed
will be determined by his device's hardware. The software might operate on devices with a single
processing core or many processing cores due to Android's mobility. Android can use several
CPU cores for multithreading, but it is handled by the kernel and JVM, not by the developer. The
program's fundamental performance will be improved by an internal multithreading architecture,
but the device on which it runs will decide its speed.
 Multi thread can be implemented for android.
 Implement the Runnable interface

The increase in number of threads within the process does not affect the response time since
there is no maximum limit for thread creation for a process. Also, the response time increases
when there are more threads. The requests will be processed by a thread which is idle
at that time and gives a quick reply.

The effect of multi-threading in android:


 Deadlocks, starvation of resources, termination etc.
 In the processors of android, it is difficult to execute multiple threads at the same time.

https://sites.google.com/site/puneetverma24android/process-and-thread/android-thread
https://sites.google.com/site/puneetverma24android/process-and-thread
https://smallbusiness.chron.com/four-ways-operating-system-controls-hardware-
computer75028.html
03 Practice Exercise 1 *Property
of STI
Page 1 of 1

You might also like