OS interview Questions for Freshers ๐Ÿ“

  • What is OS?

-> An Operating System (OS) is a collection of software that manages computer hardware resources and provides common services for computer programs. An operating system acts as an interface between the software and different parts of the computer or the computer hardware.

  • Modes of OS?

-> User mode: In user mode, the application program do not have direct access to system resources. In order to access the resources, a system call must be made.

In user mode, a single process fails if an interrupt occurs.

In user mode, all processes get separate virtual address space.

Kernel mode: : In kernel mode, the program has direct and unrestricted access to system resources.

In Kernel mode, the whole operating system might go down if an interrupt occurs.

In kernel mode, all processes share a single virtual address space.

  • Define system call

-> A system call is a mechanism used by programs to request services from the operating system (OS). In simpler terms, it is a way for a program to interact with the underlying system, such as accessing hardware resources or performing privileged operations.

  • Function of the OS:

-> Memory and Processor Management
Providing user interface to users
File Management and Device Management
Scheduling of resources and jobs
Error Detection
Security

  • Types of Operating Systems

-> There are several types of Operating Systems which are mentioned below.

Batch Operating System : This type of operating system does not interact with the computer directly. There is an operator which takes similar jobs having the same requirements and groups them into batches.

Multi-Programming System : Multiprogramming Operating Systems can be simply illustrated as more than one program is present in the main memory and any one of them can be kept in execution.

Multi-Processing System : Multi-Processing Operating System is a type of Operating System in which more than one CPU is used for the execution of resources

Multi-Tasking Operating System : Multitasking Operating System is simply a multiprogramming Operating System with having facility of a Round-Robin Scheduling Algorithm. It can run multiple programs simultaneously.

Time-Sharing Operating System : Each task is given some time to execute so that all the tasks work smoothly. Each user gets the time of the CPU as they use a single system. The time that each task gets to execute is called quantum.

Distributed Operating System : A distributed System is a collection of autonomous computer systems that are physically separated but are connected by a centralized computer network that is equipped with distributed system software

Network Operating System : a network operating system(NOS) is software that connects multiple devices and computers on the network and allows them to share resources on the network

Real-Time Operating System : A real-time operating system (RTOS) is a special kind of operating system designed to handle tasks that need to be completed quickly and on time.

There are two types of RTOS :

Hard real time : missing an occasional deadline can cause any permanent damage. Many of these are found in
industrial process control, car engine control system.

Soft real time : missing an occasional deadline does not cause any permanent damage. Used in digital audio,
multimedia system.

  • Define process & Thread:

-> Program in execution is called process.
Thread means a segment of a process.

States of process :

-> There are total 5 states : new, ready,run , block, exit

  • What is process control block:

-> A Process Control Block (PCB) is a data structure maintained by the operating system for every process.

  • What is a Pipe and when it is used?

-> The pipe is generally a connection among two or more processes that are interrelated to each other. It is a mechanism that is used for inter-process communication using message passing. One can easily send information such as the output of one program process to another program process using a pipe. It can be used when two processes want to communicate one-way i.e., inter-process communication (IPC).

  • What is bootstrap program?

-> It is generally a program that initializes OS during startup i.e., first code that is executed whenever computer system startups. OS is loaded through a bootstrapping process or program commonly known as booting.

  • Explain demand paging?

-> Demand paging is a method that loads pages into memory on demand. This method is mostly used in virtual memory. In this, a page is only brought into memory when a location on that particular page is referenced during execution.

  • Define Race condition

-> The situation where several processes access and manipulate shared data concurrently. The final value of the shared data depends upon which process finishes last.

Define Process synchronization

-> Process synchronization in OS is the task of coordinating the execution of processes in such a way that no two processes can access the same shared data and resources.

  • What is different between main memory and secondary memory.

-> Main memory: Main memory in a computer is RAM (Random Access Memory).The programs and data that the CPU requires during the execution of a program are stored in this memory.

Secondary memory: Secondary memory in a computer are storage devices that can store data and programs. Such storage devices are capable of storing high-volume data. Storage devices can be hard drives, USB flash drives, CDs, etc.

  • Critical Section:

-> Critical Section: The part of program where the shared resource is accessed is called critical section or critical region.

  • What is thrashing in OS?

-> It is generally a situation where the CPU performs less productive work and more swapping or paging work. It spends more time swapping or paging activities rather than its execution.

  • What do you mean by Sockets in OS?

-> The socket in OS is generally referred to as an endpoint for IPC (Interprocess Communication). Here, the endpoint is referred to as a combination of an IP address and port number.

  • What do you mean by cascading termination?

-> Cascading termination is a process termination in which if the parent process is exiting or terminating then the children process will also get terminated. It does not allow the child to continue processing as its parent process terminates. It is generally initiated by OS.

  • Define Aging

-> It simply increases the priority of processes that wait in the system for resources for a long period of time.

  • What is the difference between paging and segmentation?

-> Paging: It is generally a memory management technique that allows OS to retrieve processes from secondary storage into main memory. It is a non-contiguous allocation technique that divides each process in the form of pages.

Segmentation: It is generally a memory management technique that divides processes into modules and parts of different sizes. These parts and modules are known as segments that can be allocated to process.

What is virtual memory?

-> It is a memory management technique feature of OS that creates the illusion to users of a very large (main) memory. It is simply space where a greater number of programs can be stored by themselves in the form of pages.

  • What do you mean by Semaphore in OS? Why is it used?

-> Semaphore is a normal variable that is used to control access to shared resources in multi-threaded or multi-process systems. It maintains a count of available resources and provides two atomic operations: wait() and signal().

Types of Semaphores

There are two main types of semaphores:

Binary semaphore: A binary semaphore is a synchronization object that can only have two values: 0 and 1.

Counting semaphore: A counting semaphore is a synchronization object that can have a value greater than 1.

  • Write difference between micro kernel and monolithic kernel?

-> MicroKernel : In this software or program, kernel services and user services are present in different address spaces.

If a service crashes, it does affect on working of the microkernel.

Monolithic Kernel: In this software or program, kernel services and user services are usually present in the same address space.

If a service crashes, the whole system crashes in a monolithic kernel.

  • What do you mean by Beladyโ€™s Anomaly?

-> Beladyโ€™s Anomaly is a phenomenon in which if we increase the number of frames in memory, then the number of page faults also increases. It is generally experienced when we use FIFO (First in First out) page replacement algorithm.

  • Necessary Conditions for Deadlock

-> There are basically four necessary conditions for deadlock as given below:

Mutual Exclusion: Mutual Exclusion condition requires that at least one resource be held in a non-shareable mode, which means that only one process can use the resource at any given time.

Hold and Wait: The hold and wait condition specifies that a process must be holding at least one resource while waiting for other processes to release resources that are currently held by other processes.

No Pre-emption: resources cannot be taken forcibly from a process a process can only release resources voluntarily after completing its task.

Circular Wait or Resource Wait: This condition implies that circular processes must exist, with each process waiting for a resource held by the next process in the chain.

  • What are overlays?

-> The concept of overlays is that whenever a process is running it will not use the complete program at the same time, it will use only some part of it.

  • What is Buffer?

-> A buffer is a memory area that stores data being transferred between two devices or between a device and an application.

  • What is Banker’s Algorithm?

-> The Bankers Algorithm in OS is a deadlock avoidance algorithm used to avoid deadlocks and to ensure safe execution of processes. The algorithm maintains a matrix of maximum and allocated resources for each process and checks if the system is in a safe state before allowing a process to request additional resources.

  • Logical Address vs Physical Address?

-> Logical:

Logical Address Space is a set of all logical addresses generated by the CPU in reference to a program.

Logical address are generated by CPU.

Users can view the logical address of a program.

Physical Address:

Physical Address is a real address where actual data has been stored in the machine and set of all physical addresses mapped to the corresponding logical addresses.

Computed by MMU.

Users can never view the physical address of the program.

  • What is Interrupt?

-> The interrupt is a signal emitted by hardware or software when a process or an event needs immediate attention. It alerts the processor to a high-priority process requiring interruption of the current working process. In I/O devices one of the bus control lines is dedicated for this purpose and is called the Interrupt Service Routine (ISR).

  • What is the Direct Access Method?

-> Direct memory access (DMA) is a method that allows an input/output (I/O) device to send or receive data directly to or from the main memory, bypassing the CPU to speed up memory operations. The process is managed by a chip known as a DMA controller (DMAC).

  • What is Cycle Stealing?

-> Cycle stealing is a method of accessing computer memory (RAM) or bus without interfering with the CPU. It is similar to direct memory access (DMA) for allowing I/O controllers to read or write RAM without CPU intervention.

  • What is a trapdoor in OS?

-> A trap door is a method of gaining access to information or z/OS features that are normally beyond a user’s access authority. The distinguishing feature of a trap door is that it is intentionally hidden and used only when needed.

  • What is a dispatcher?

-> The dispatcher is the module that gives process control over the CPU after it has been selected by the short-term scheduler. This function involves the following:

Switching context
Switching to user mode
Jumping to the proper location in the user program to restart that program

  • What is a critical- section?

-> When more than one processes access the same code segment that segment is known as the critical section. The critical section contains shared variables or resources which are needed to be synchronized to maintain the consistency of data variables.

  • Also Go through the Following Topics :

    • Critical section problem
    • Solution for critical section: Software, Hardware, OS based solution
    • Peterson Algorithm
    • Banker Algorithm
    • Semaphore in detail
    • Semaphore solution for the Producer Consumer Problem, Dinning Philosopher Problem, Reader Writer Problem.

Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top