Concurrent processing
Is a computing model in which multiple processors execute instructions
simultaneously for better performance. Concurrent means, which occurs
when something else happens. The tasks are broken into subtypes,
which are then assigned to different processors to perform
simultaneously, sequentially instead, as they would have to be
performed by one processor. Concurrent processing is sometimes
synonymous with parallel processing. The term real and virtual
concurrency in concurrent processing:
1. Multiprogramming Environment: In a multiprogramming
environment, there are multiple tasks shared by one processor. While
a virtual concept can be achieved by the operating system, if the
processor is allocated for each individual task, the virtual concept is
visible if each task has a dedicated processor. The multilayer
environment is shown in figure.
2. Multiprocessing Environment: In multiprocessing environment two or more
processors are used with shared memory. Only one virtual address space is
used, which is common for all processors. All tasks reside in shared memory. In
this environment, concurrency is supported in the form of concurrently executing
processors. The tasks executed on different processors are performed with each
other through shared memory. The multiprocessing environment is shown in
figure.
3. Distributed Processing Environment: In a distributed processing
environment, two or more computers are connected to each other by
a communication network or high speed bus. There is no shared
memory between the processors and each computer has its own local
memory. Hence a distributed application consisting of concurrent
tasks, which are distributed over network communication via
messages. The distributed processing environment is shown in figure.
Interactive Process in Operating System
Definition
An interactive process is a type of process in an operating system that requires continuous
interaction with the user. It often involves input/output operations such as keyboard
typing, mouse clicking, or touch events, and the system must provide a quick response to
keep the user engaged.
These processes are user-centric and need fast response time to ensure smooth interaction.
Examples
Typing in a text editor (MS Word, Notepad, etc.)
Playing a video game
Browsing the web
Chatting in a messaging app
Using a GUI-based program like Photoshop
Characteristics of Interactive Processes
1. User-driven – Execution depends on user actions.
2. High priority for responsiveness – The OS ensures low waiting time for good user
experience.
3. I/O bound – Spend more time waiting for input/output than using CPU.
4. Short bursts of CPU usage – Need quick CPU attention but not long continuous
processing.
5. Time-sharing requirement – Often managed with round robin or priority
scheduling to ensure responsiveness.
How OS Handles Interactive Processes
Preemptive Scheduling – CPU can be taken away from other processes to serve an
interactive one.
Priority Levels – Interactive processes usually have higher priority than batch
processes.
Time Quantum – Smaller time slices are assigned so that the process doesn’t wait
too long.
Fast I/O handling – Efficient interrupt handling for devices like keyboard, mouse,
etc.
Would you like me to also make a diagram/flow chart showing how the OS handles
an interactive process step by step?
Threads
In an operating system, a thread is a lightweight unit of execution within a process. A
process is an instance of a program that is being executed, and a thread is a subset of
the process that can run concurrently with other threads within the same process.
Threads share resources with other threads in the same process, such as memory, file
handles, and network connections, which makes them more efficient than processes.
Threads in operating systems can be used to improve the responsiveness and
efficiency of multi-tasking applications by allowing different parts of the program to
execute concurrently. They can also be used to perform background tasks, such as I/O
operations or network communication, without blocking the main thread or other
threads.
In modern operating systems, threads are managed by the kernel, which provides
services such as scheduling, synchronization, and communication between threads.
Operating systems use different thread models, such as the one-to-one model, where
each user-level thread is mapped to a kernel thread, or the many-to-many model,
where multiple user-level threads can be mapped to a smaller number of kernel
threads.
The process can be split down into so many threads. For example, in a browser, many
tabs can be viewed as threads. MS Word uses many threads - formatting text from one
thread, processing input from another thread, etc.
Types of Threads
In the operating system, there are two types of threads.
1. Kernel level thread.
2. User-level thread.
User-level thread
The user-level thread is ignored by the operating system. User threads are
simple to implement and are done so by the user. The entire process is
blocked if a user executes a user-level operation of thread blocking. The
kernel-level thread is completely unaware of the user-level thread. User-
level threads are managed as single-threaded processes by the kernel-
level thread.
Threads in Java, POSIX, and other languages are examples.
Pros
o User threads are easier to implement than kernel threads.
o Threads at the user level can be used in operating systems that do not allow threads
at the kernel level.
o It is more effective and efficient.
o Context switching takes less time than kernel threads.
o It does not necessitate any changes to the operating system.
o The representation of user-level threads is relatively straightforward. The user-level
process's address space contains the register, stack, PC, and mini thread control blocks.
o Threads may be easily created, switched, and synchronised without the need for
process interaction.
Cons
o Threads at the user level are not coordinated with the kernel.
o The entire operation is halted if a thread creates a page fault.
Kernel level thread
The operating system is recognised by the kernel thread. Each thread and process in
the kernel-level thread has its own thread control block as well as process control block
in the system. The operating system implements the kernel-level thread. The kernel is
aware of all threads and controls them. The kernel-level thread provides a system call
for user-space thread creation and management. Kernel threads are more complex to
build than user threads. The kernel thread's context switch time is longer. The
execution of the Banky thread can continue in case a kernel thread performs a blocking
operation.
Example: Window Solaris.
Advantages of Kernel-level threads
1. The kernel-level thread is fully aware of all threads.
2. The scheduler may decide to spend more CPU time in the process of threads being
large numerical.
3. The kernel-level thread is good for those applications that block the frequency.
4. Threads improve the overall performance of a program.
5. Threads increase the responsiveness of the program
6. Context switching time in threads is faster.
7. Threads share the same memory and resources within a process.
8. Communication is faster in threads.
9. Threads provide concurrency within a process.
10. Enhanced throughput of the system.
11. Since different threads can run parallelism, threading enables the utilization of the
multiprocessor architecture to a greater extent and increases efficiency.
Cons
o All threads are managed and scheduled by the kernel thread.
o Kernel threads are more complex to build than user threads.
o Kernel-level threads are slower than user-level threads.