Operating Systems Technical Interview Questions

What is an Operating System?

An Operating System (OS) is nothing more than a program. However, it is the most important program that runs on a computer. The OS is the responsible for running all the programs and applications that run in the computer.

The OS may or may not have a graphical user interface (GUI), but will have some sort of user interface (UI), even if it is just a command line. This UI is what allows the users to interact with the OS and command it to run which program and when.

It can be said that the OS is the manager of the computer, as it recognizes which hardware devices are connected to the computer, as well as handles the input and output from those devices. It also runs and manages multiple applications, as well as handles the sharing of internal memory among them. It also ensures that the different programs running do not interfere with each other. The operating system is also responsible for security. It ensures that unauthorized users do not access the system.

An Operating System is the core of any computer or device. It is the most important program that runs on the computer, as it is responsible for running all the other programs and applications that run in the computer.  An Operating System has three primary functions:  To run and  manage all the programs that are running on the system as well as allocate resources to them To monitor the performance of each of the different parts, such as the central processing unit, memory, disk drives, and printers To build

An Operating System is the core of any computer or device. It is the most important program that runs on the computer, as it is responsible for running all the other programs and applications that run in the computer.

An Operating System has three primary functions:

  • To run and  manage all the programs that are running on the system as well as allocate resources to them
  • To monitor the performance of each of the different parts, such as the central processing unit, memory, disk drives, and printers
  • To build an interface that brings the user closer to the system via the use of different modules and libraries

What is a process and process table? What are different states of process?

A process is an instance of a computer program that is being executed; basically the functions of a computer program are broken down into process.  

A process table is a table which lists the processes that are undergoing. This table must be saved when the CPU switches from running one process to another in a multitasking system. The benefit of a process table is that it allows a suspended process to be restarted at a later time as if it had never been stopped.

There are three different states of process: running, ready, or waiting. A running process is a process that is currently running. A ready process is one that is ready to be executed, whereas a waiting process is one that is waiting to be executed.

These categories primarily refer to resource allocation. The running state means that the process has all the resources it need for execution and it has been given permission by the operating system to use the processor. However, only one process can be in the running state at any given time. All other processes must be either ready, or waiting. In the waiting state, the process is waiting for some external event to occur such as user input or a disk access, while in the ready state, the process is waiting for permission to use the processor.

What is a Thread? What are the differences between process and thread?

A thread is a single sequence stream within in a process. Each process is made up of various different threads. Threads are also often referred to as lightweight processes, primarily because they have some of the properties as processes.

Threads are part of processes. It can be said that a process can be broken down into threads. Each process must have at least one thread. A process can have multiple threads in addition to the primary thread.

Process

Thread

Run in separate memory spaces

Run in a shared memory space

Self-contained execution environment

Part of a process, hence share its execution environment

Has a complete, private set of basic run time resources

Part of a process, hence shares its basic run time resources

Only a single process can run at a time

Multiple threads can run at a time

Have their own copy of the data segment

Have direct access to the data segment

Changes to the parent process does not affect child processes

Changes to the main thread may affect the behavior of the other threads of the process

Heavily dependent on system resources

Require minimal amounts of resource

What is deadlock?

Deadlock is an event where two or more programs are competing for the same resources. Here the programs are in a deadlock because neither one can progress ahead.

Deadlock is a situation that occurs when two computer programs are sharing the same resources, and are thus effectively preventing each other from accessing the resource. This results in both the programs not being able to function.

Originally all computers were one program at a time type operating systems. Hence, at the time the program was running, all of the system’s resources were available to that program. However, as technology improved, more and more users tended to run multiple programs at the same time, hence these programs need to compete for the same resources.

What are the necessary conditions for deadlock?

Deadlock is a condition where two or more computer programs that must compete for the same resources, block each other thus resulting in neither one being able to function. However, deadlocks occur when these four conditions occur simultaneously:

  • Mutual Exclusion – where resources shared such as read-only files do not lead to deadlocks but resources, such as printers and tape drives, requires exclusive access by a single process.
  • Hold and Wait – where processes must be prevented from holding one or more resources while simultaneously waiting for one or more others.
  • No Preemption – where the preemption of process resource allocations can avoid the condition of deadlocks, where ever possible.
  • Circular Wait – which can be avoided if all the resources are numbers, and require that processes request resources only in strictly increasing (or decreasing) order.

If any of these conditions can be prevented then the deadlock should not occur.

What is Virtual Memory? How is it implemented?

Virtual Memory is a type of memory management system that aims to harness more memory than is physically available. It is implemented by using hardware and software in lieu of physical memory. The data is temporarily transferred from random access memory (RAM) to disk storage.

Virtual memory serves two functions:

  • it allows for the extended the use of physical memory by using disk
  • it allows for memory protection as each virtual address is translated to a physical address.
What is Thrashing?

Thrashing is a high paging activity. It occurs when the computer activity make little or no progress. It usually occurs because memory or other resources have become too exhausted or are too limited to perform the needed operations. However, the computer's virtual memory subsystem continuously keeps paging, where the data in memory is rapidly exchanged for data on disk.

Thrashing occurs when the system does not have enough memory. Or it may alternately happen when the system swap file is not properly configured, when too much is running at the same time, or the system has low system resources.

Thrashing is bad for the computer as the hard drive is always working, which results in a decrease in system performance. It left unattended it can lead to early hard drive failure.

http://interviewquestionanswer.com/sites/default/files/2017/05/article_thumb/What-is-Belady%E2%80%99s-Anomaly.jpg

Bélády's anomaly is a phenomenon where the increasing the number of page frames results in an increase in the number of page faults for certain memory access patterns. It is also known as FIFO anomaly, as it results in a FIFO page replacement policy.

Typically, when the number of frames allocated to a process virtual memory are increased, the process execution is usually faster, because fewer page faults occur. However, Belady’s Anomaly proves that sometime the opposite is true. Sometimes, the execution time increases even when more frames are allocated to the process.

An operating system is a type of system software that manages all of the resources of the hardware and the software. It also provides common services for computer programs. All computer programs, with the exception of firmware, require an operating system to function.

An operating system serves three main purposes; one is to ensure that a computer system performs well by managing the computer's resources, such as the central processing unit, memory, disk drives, and printers. The other is to provide an environment for the development and execution of programs. The third and sometimes the most important is to establish a user interface.

There are five different types of operating systems. They are the following:

  1. Batched operating systems – users of a batch operating system do not interact with the computer directly
  2. Multi-programmed operating systems – allows more than one program to run at the same time.
  3. Timesharing operating systems – Time-sharing allows many people, located at various terminals, to use a particular computer system at the same time.
  4. Distributed operating systems – a software distributed over a collection of independent, networked, communicating, and physically separate computational nodes
  5. Real-time operating systems – the time interval required to process and respond to inputs is so small that it controls the environment.

The term process refers to any program that is in execution.

There are two main types of processes. These are:

  1. Operating system processes
  2. User processes

A process is a program that is in execution. Each process follows various states, which are

  1. New – a process that is just started and is new
  2. Running – a process that is already running
  3. Waiting – a process that is waiting
  4. Ready – a process that is done and ready
  5. Terminated – a process that is finished and/or stopped and deleted.

A kernel is the core or the central part of the operating system. Each operating system has its own kernel. The kernel connects the applications to the actual processing of the data. It also manages all communications between software and hardware components in order to ensure usability and reliability. It also manages the tasks of the computer and the hardware , specifically the memory and CPU time.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.