Operating System Interview Questions

download Operating System Interview Questions

of 12

Transcript of Operating System Interview Questions

  • 7/30/2019 Operating System Interview Questions

    1/12

    Operating system interview questions

    Q1.Explain the meaning of Kernal.

    Answer

    The kernel is the essential center of a computer operating system, the core that provides basic services for all other

    parts of the operating system.

    As a basic component of an operating system, a kernel provides the lowest-level abstraction layer for the resources.

    The kernel's primary purpose is to manage the computer's resources and allow other programs to run and use the

    resources like the CPU, memory and the I/O devices in the computer.

    The facilities provides by the kernel are :

    Memory managementThe kernel has full access to the system's memory and must allow processes to access safely this memory

    as they require it.

    Device managementTo perform useful functions, processes need access to the peripherals connected to the computer, which

    are controlled by the kernel through device drivers

    System callsTo actually perform useful work, a process must be able to access the services provided by the kernel.

    Types of Kernel:

    Monolithic kernelsEvery part which is to be accessed by most programs which cannot be put in a library is in the kernel space:

    Device drivers

    Scheduler

    Memory handling

    File systemsNetwork stacks

    MicrokernlsIn Microkernels, parts which really require to be in a privileged mode are in kernel space:

    -Inter-Process Communication,

    -Basic scheduling

    -Basic memory handling

    -Basic I/O primitives

    Due to this, some critical parts like below run in user space:

    The complete scheduler

    Memory handling

    File systems Network stacks

    Q2.Explain the meaning of Kernel.

    Kernel is the core module of an operating system. It is the kernel that loads first and retain in main memory of the

    computer system. It provides all essential operations /services those are needed by applications. Kernel takes the

    responsibility of managing the memory, task, disk and process.

  • 7/30/2019 Operating System Interview Questions

    2/12

    Q3.What is a command interpreter?

    Answer

    The part of an Operating System that interprets commands and carries them out.

    A command interpreter is the part of a computer operating system that understands and executes commands that are

    entered interactively by a human being or from a program. In some operating systems, the command interpreter is

    called the shell.

    The BIOS is looking for the files needed to load in case of Windows is the Command.com. The required files are

    Command.com, IO.sys, and Msdos.sys to get Windows started. They reside in the Root of the C Drive.

    Q4.What is a daemon?

    In Unix and some other operating systems, a daemon is a computer program that runs in the background, It is not

    under the direct control of a user.

    They are usually initiated as background processes. Daemons have names that end with the letter "d".

    E.g. syslogd, sshd

    In a Unix, the parent process of a daemon is usually the init process (PID=1). Processes usually become daemons by

    forking a child process and then having their parent process immediately exit, thus causing init to adopt the child

    process.

    Q5.Explain the basic functions of process management.

    Answer

    The basic functions of the OS wrt the process management are :

    Allocating resources to processes,

    enabling processes to share and exchange information,

    protecting the resources of each process from other processes and

    enabling synchronisation among processes.

    Q6.What is a named pipe?

    Answer

    A connection used to transfer data between separate processes, usually on separate computers.

    Its a pipe that an application opens by name in order to write data into or read data from the pipe.They are placed in the /dev directory and are treated as special files.

    Using a named pipe facilitates interprocess communications.

  • 7/30/2019 Operating System Interview Questions

    3/12

    Q7.What is pre-emptive and non-preemptive scheduling?

    Answer

    Tasks are usually assigned with priorities. At times it is necessary to run a certain task that has a higher priority

    before another task although it is running. Therefore, the running task is interrupted for some time and resumed laterwhen the priority task has finished its execution. This is called preemptive scheduling.

    Eg: Round robin

    In non-preemptive scheduling, a running task is executed till completion. It cannot be interrupted.

    Eg First In First Out

    Q8.What is a semaphore?

    Answer

    A semaphore is a variable. There are 2 types of semaphores:

    Binary semaphoresCounting semaphores

    Binary semaphores have 2 methods associated with it. (up, down / lock, unlock)

    Binary semaphores can take only 2 values (0/1). They are used to acquire locks. When a resource is available, the

    process in charge set the semaphore to 1 else 0.

    Counting Semaphore may have value to be greater than one, typically used to allocate resources from a pool of

    identical resources.

    Q9.What is difference between binary semaphore and mutex?

    The differences between binary semaphore and mutex are:

    Mutex is used exclusively for mutual exclusion. Both mutual exclusion and synchronization can be used bybinary.

    A task that took mutex can only give mutex.

    From an ISR a mutex can not be given.

    Recursive taking of mutual exclusion semaphores is possible. This means that a task that holds beforefinally releasing a semaphore, can take the semaphore more than once.

    Options for making the task which takes as DELETE_SAFE are provided by Mutex, which means the taskdeletion is not possible when holding the mutex.

    Q10.Explain the meaning of mutex.

    AnswerA mutex and the binary semaphore are essentially the same. Both can take values: 0 or 1. However, there is a

    significant difference between them that makes mutexes more efficient than binary semaphores.

    A mutex can be unlocked only by the thread that locked it. Thus a mutex has an owner concept.

    What are the different types of memory?

    The memory types are:

  • 7/30/2019 Operating System Interview Questions

    4/12

  • 7/30/2019 Operating System Interview Questions

    5/12

    A critical task obtains a priority over other tasks and maintaining that priority until the completion of the task. This is

    performed by a soft real time system. The system kernel delays need to be bounded as in the case of hard real time

    system

    Q14.What type of scheduling is there in RTOS?

    The tasks of real time operating system have 3 states namely, running, ready, blocked. Only one task per CPU isbeing performed at a given point of time. In systems that are simpler, the list is usually short, two or three tasks at the

    most.

    The designing of scheduler is the real key. Usually to minimize the worst-case length of time spent in the schedulers

    critical section, the data structure of the ready list in the scheduler is designed. This is done during the inhibition of

    preemption. All interrupts are disabled in certain cases. The data structure choice depends on the tasks on the ready

    list can perform at the maximum.

    Q15.What is interrupt latency?

    The time between a device that generates an interrupt and the servicing of the device that generated the interrupt is

    known as interrupt latency. Many operating systems devices are serviced soon after the interrupt handler of the

    device is executed. The effect of interrupt latency may be caused by the interrupt controllers, interrupt masking, and

    the methods that handle interrupts of an operating system

    Q16.What is priority inheritance?

    Priority inversion problems are eliminated by using a method called priority inheritance. The process priority will be

    increased to the maximum priority of any process which waits for any resource which has a resource lock. This is the

    programming methodology of priority inheritance.

    When one or more high priority jobs are blocked by a job, the original priority assignment is ignored and execution of

    critical section at the highest priority level of jobs it blocks is performed. The job returns to the original priority level

    soon after executing the critical section. This is the basic idea of priority inheritance protocol

    Q17.What is spin lock?

    In a loop a thread waits simply (spins) checks repeatedly until the lock becomes available. This type of lock is a spin

    lock. The lock is a kind of busy waiting, as the threads remains active by not performing a useful task. The spin locks

    are to release explicitly, although some locks are released automatically when the tread blocks

    18.What is an operating system? What are the functions of an operating system?

    An operating system is an interface between hardware and software. OS is responsible for managing and co-

    ordinating the activities of a computer system.

    Functions of an operating system: Every operating system has two main functions

    1. Operating system makes sure that the data is saved in the required place on the storage media. Programs are

    loaded into the memory properly, and the file system of OS will keep the files in the order.

    2. OS enables the hardware and software to interact and perform functionality like, printing, scanning, mouse

    operations, web cam operations. OS allows application softwares to interact with the hardware

  • 7/30/2019 Operating System Interview Questions

    6/12

    Q19.What is paging? Why paging is used?

    OS performs an operation for storing and retrieving data from secondary storage devices for use in main memory.

    Paging is one of such memory management scheme. Data is retrieved from storage media by OS, in the same sized

    blocks called as pages. Paging allows the physical address space of the process to be non contiguous. The whole

    program had to fit into storage contiguously.

    Paging is to deal with external fragmentation problem. This is to allow the logical address space of a process to be

    noncontiguous, which makes the process to be allocated physical memory.

    Q20.Difference between a process and a program

    - A program is a set of instructions that are to perform a designated task, where as the process is an operation which

    takes the given instructions and perform the manipulations as per the code, called execution of instructions. A

    process is entirely dependent of a program.

    - A process is a module that executes modules concurrently. They are separate loadable modules. Where as the

    program perform the tasks directly relating to an operation of a user like word processing, executing presentation

    software

    Q21.What is the meaning of physical memory and virtual memory?

    Physical memory is the only memory that is directly accessible to the CPU. CPU reads the instructions stored in the

    physical memory and executes them continuously. The data that is operated will also be stored in physical memory in

    uniform manner.

    Virtual memory is one classification of memory which was created by using the hard disk for simulating additional

    RAM, the addressable space available for the user. Virtual addresses are mapped into real addresses.

    Q22.What is the difference between socket and pipe?

    Sockets:

    Socket is a part of OSI layer model. Communication among different layers is performed through sockets. Application

    layer serves through some sockets to the presentation layer and upper application layer.

    Sockets are used in Secure Socket Layer networks.

    Communication is in bi-directional in sockets.

    Pipes:

    Pipes are related to processing in CPU.

    Pipes are the segments for processes in execution. By processing multiple processes simultaneously, the productivity

    can be improved.

    Communication is uni-directional in pipes

    Q23.What are the difference between THREAD, PROCESS and TASK?

    A program in execution is known as process. A program can have any number of processes. Every process has its

    own address space.

  • 7/30/2019 Operating System Interview Questions

    7/12

    Threads uses address spaces of the process. The difference between a thread and a process is, when the CPU

    switches from one process to another the current information needs to be saved in Process Descriptor and load the

    information of a new process. Switching from one thread to another is simple.

    A task is simply a set of instructions loaded into the memory. Threads can themselves split themselves into two or

    more simultaneously running tasks.

    Q24.Difference between NTFS and FAT32

    The differences are as follows:

    NTFS:

    - Allows the access local to Windows 2000, Windows 2003, Windows NT with service pack 4 and later versions may

    get access for some file.

    - Maximum partition size is 2TB and more.

    - Maximum size of file is upto 16TB

    - File and folder encryption is possible.

    FAT 32:

    - Allows the access local to Windows 95, Windows 98, Windows ME, Windows 2000, Windows xp on local partition.

    - Maximum partition size is 2TB

    - Maximum size of file is upto 4GB

    - File and folder encryption is not possible

    Q25.Differentiate between RAM and ROM

    RAM:

    - Volatile memory

    - Electricity needs to flow continuously- Program information is stored in RAM

    - RAM is read / write memory

    - Cost is high

    ROM:

    - Permanent memory

    - Instructions are stored in ROM permanently.

    - BIOS has information to boot the system

    - ROM is read only memory

    - Access speed is less

    Q26.What is DRAM? In which form does it store data?

    DRAM Dynamic Random Access Memory. One of the read / write memory. DRAM is cheap and does the given

    task. DRAM has cells made up of a capacitor and a transistor, where the data resides. Capacitors need to recharge

    for every couple of milliseconds. The process of recharging cells tends to performance slow down of DRAM as

    compared with speedier RAM types

  • 7/30/2019 Operating System Interview Questions

    8/12

    Q27.What is cache memory? Explain its functions

    Cache memory is RAM. The most recently processing data is stored in cache memory. CPU can access this data

    more quickly than it can access data in RAM. When the microprocessor starts processing the data, it first checks in

    cache memory.

    The size of each cache block ranges from 1 to 16 bytes. Every location has an index that corresponds to the locationwhich has data to access. This index is known as address. The locations have tags; each contains the index and the

    datum in the memory that is needed to be cached.

    Q28.What is the function of SMON?

    The SMON background process performs all system monitoring functions on the oracle database.

    Each time oracle is re-started, SMON performs a warm start and makes sure that the transactions that were left

    incomplete at the last shut down are recovered.

    SMON performs periodic cleanup of temporary segments that are no longer needed

    Q29.Explain different types of segment.

    There are four types of segments used in Oracle databases:

    - data segments

    - index segments

    - rollback segments

    - temporary segments

    Data Segments:

    There is a single data segment to hold all the data of every non clustered table in an oracle database. This data

    segment is created when you create an object with the CREATE TABLE/SNAPSHOT/SNAPSHOT LOG command.

    Also, a data segment is created for a cluster when a CREATE CLUSTER command is issued.

    The storage parameters control the way that its data segment's extents are allocated. These affect the efficiency of

    data retrieval and storage for the data segment associated with the object.

    Index Segments:

    Every index in an Oracle database has a single index segment to hold all of its data. Oracle creates the index

    segment for the index when you issue the CREATE INDEX command. Setting the storage parameters directly affects

    the efficiency of data retrieval and storage.

    Rollback Segments

    Rollbacks are required when the transactions that affect the database need to be undone. Rollbacks are also needed

    during the time of system failures. The way the roll-backed data is saved in rollback segment, the data can also be

    redone which is held in redo segment.

    A rollback segment is a portion of the database that records the actions of transactions if the transaction should be

    rolled back. Each database contains one or more rollback segments. Rollback segments are used to provide read

    consistency, to rollback transactions, and to recover the database.

    Types of rollbacks:

    - statement level rollback

    - rollback to a savepoint

  • 7/30/2019 Operating System Interview Questions

    9/12

    - rollback of a transaction due to user request

    - rollback of a transaction due to abnormal process termination

    - rollback of all outstanding transactions when an instance terminates abnormally

    - rollback of incomplete transactions during recovery.

    Temporary Segments:

    The SELECT statements need a temporary storage. When queries are fired, oracle needs area to do sorting andother operation due to which temporary storages are useful.

    The commands that may use temporary storage when used with SELECT are:

    GROUP BY, UNION, DISTINCT, etc.

    Q30. Explain SGA memory structures.

    SGA (System Global Area) is a dynamic memory area of an Oracle Server. In SGA,the allocation is done in granuels.

    The size of the SGA is dependent on SGA_MAX_SIZE parameter.

    The memory structures contained by SGA are:-

    Shared Pool -

    this memory structure is divided into two sub-structures which are Library Cache and Data Dictionary Cache for

    storing recently used PL/SQL statements and the recent data definitions. The maximum size of the Shared Pool

    depends on the SHARED_POOL_SIZE parameter.

    Database Buffer Cache

    This memory structure improves the performance while fetching or updating the recently used data as it stores the

    recently used datafiles. The size of this block is decided by DB_BLOCK_SIZE.

    Redo Log Buffer

    This memory structure is used to store all the changes made to the database and it's primarily used for the data

    recovery purposes. The size of this block is decided by LOG_BUFFER.

    Java Pool

    This memory structure is used when Java is installed on the Oracle server. Size that can be used is stored in

    parameter named JAVA_POOL_SIZE.

    Large Pool

    This memory structure is used to reduce the burden of the Shared Pool, as the Session memory for the Shared

    Server, as the temporary storage for the I/O and for the backup and restore operations or RMAN. Parameter that

    stores the maximum size is LARGE_POOL_

    Q31.What is SQL Loader? Explain the files used by SQL Loader to load file.

    SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. SQL*Loader

    supports various load formats, selective loading, and multi-table loads.

    When a control file is fed to an SQL*Loader, it writes messages to the log file, bad rows to the bad file and discarded

    rows to the discard file.

    Control file

    The SQL*Loader control file contains information that describes how the data will be loaded. It contains the table

    name, column datatypes, field delimiters, etc.

    controlfile.sql should be used to generate an accurate control file for a given table.

  • 7/30/2019 Operating System Interview Questions

    10/12

    Log File

    The log file contains information about the SQL*loader execution. It should be viewed after each SQL*Loader job is

    complete

    Q32.Explain the methods provided by SQL Loader.

    Conventional Path Load and Direct Path Load are the two methods of loading data.

    Conventional Path Loadis the default loading method and uses the SQLs INSERT statements. It takes the

    following form:

    INSERT INTO TABLE T partition (P) VALUES ...

    The row is loaded if it maps with the portioned else an error log is written.

    Direct Path Load: This method is faster than the conventional load method. In this method, the data to be loaded is

    parsed as per the description in the loader control file. It converts data for each input field with its corresponding data

    type and builds pairs in the form of pairs). The SQL *Loader then uses these pairs to build index keys

    and formats the oracle data blocks as per the pairs. These blocks are then written into the database. This reduces the

    processing load as compared to INSERT

    Q33.What is the physical and logical structure of oracle?

    Logical Database structures

    Logical structures include tablespaces, schema objects, data blocks, extents and segments.

    Tablespaces

    Database is logically divided into one or more tablespaces. Each tablespace creates one or more datafiles to

    physically store data.

    Schema objectsSchema objects are the structure that represents database's data. Schema objects include structures such as tables,

    views, sequences, stored procedures, indexes, synonyms, clusters and database links.

    Data Blocks

    Data block represents specific number of bytes of physical database space on disk.

    Extents

    An extent represents continuous data blocks that are used to store specific data information.

    Segments

    A segment is a set of extents allocated for a certain logical structure.

    Physical database structure

    The physical database structure comprises of datafiles, redo log files and control files

    Datafiles

    Datafiles contain database's data. The data of logical data structures such as tables and indexes is stored in datafiles

    of the database. One or more datafiles form a logical unit of database storage called a tablespace.

    Redo log f i les

    The purpose of these files is to record all changes made to data. These files protect database against failures.

    Control f i les

  • 7/30/2019 Operating System Interview Questions

    11/12

  • 7/30/2019 Operating System Interview Questions

    12/12

    Q40.What is page fault and when does it occur?

    A page is a fixed length memory block used as a transferring unit between physical memory and an external storage.

    A page fault occurs when a program accesses a page that has been mapped in address space, but has not been

    loaded in the physical memory

    Q41.Define Thread.

    Threads are small processes that for parts of a larger process. A thread is contained inside a process. Different

    threads in the same process share some resources

    Q42.What are the advantages of using Thread?

    Some advantages of using threads are:

    - A process switching takes a longer time than that by threads.

    - They can execute in parallel on a multiprocessor.

    - Threads can share address spaces

    Q43.Compare Thread and process.

    Threads

    Share address space

    Have direct access to data segment of its process

    Can communicate with other threads of the same process

    Have no overhead

    If a main thread gets affected, other threads to can get affected

    Processes

    Have own address space

    Have own copy of data segment of the parent process

    Processes must use IPC for communication within sibling processes

    Have considerable overhead

    Change in a parent process has no effect on the child processes