Operating Systems CS3502 Midterm

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

All computers follow roughly the same set of steps to transition from a power-off state to a running state. Can you enumerate the steps of the booting sequence?

BIOS > MBR > Active Partition > Boot Loader BIOS Bootstrap program is loaded at power-up or reboot •Typically stored in ROM or EPROM, generally known as firmware •Initializes all aspects of system •Loads operating system kernel and starts execution initializes hardware

What do you know about BIOS? In the class we discussed that PC/BIOS PROM monitor is rather limited in its ability to access the system hardware. What new standard is being proposed to replace the traditional legacy BIOS?

Basin Input Output System, stored in ROM. PROM - Programmable Read only. UEFI - Unified Extensible Firmware Interface.

What is the difference, if any, between the following terms: Batch vs. interactive operating system

Batch processing is the execution of a series of programs or only one task on a computer environment without manual intervention. All data and commands are preselected through scripts or command-line parameters and therefore run to completion without human contact. This is termed as "batch processing" or "batch job" because the input data are collected into batches of files and are processed in batches by the program. Interactive sessions prompt the user for input as data or commands. Typically, in an interactive session there is a software running on a computer environment and accepts input from human. This is the simplest way to work on any system - you simply log on and run whatever commands you need to, whether on the command line or in a graphical environment and you log out when you've finished.

What do you mean by big-endian and little-endian system?

Big-endian is an order in which the "big end" (most significant value in the sequence) is stored first (at the lowest storage address). Little-endian is an order in which the "little end" (least significant value in the sequence) is stored first.

Describe three general methods for passing parameters to the operating system in a system call

(1) Pass the parameters in registers (this may prove insufficient when there are more parameters than registers). (2) Store the parameters in a block, or table, in memory, and pass the address of block as a parameter in a register. (3) Push the parameters onto a stack; to be popped off by the OS. Block and stackmethods do not limitt the number or length of parameters passed.

How to count number of processes created by fork()

(2^n)-1

How many processes are created if the following program is run? main(int argc, char ** argv) { forkthem( 5) ; } void forkthem (int n) { If ( n > 0) { fork(); forkthem(n-1); } } }

31

From a Linux perspective, briefly (2 sentences) describe the use of user id (a number) and group id (a number)

A UID (user identifier) is a number assigned by Linux to each user on the system. This number is used to identify the user to the system and to determine which system resources the user can access. Groups can be assigned to logically tie users together for a common security, privilege and access purpose. It is the foundation of Linux security and access

The following questions relate to BootLoaders What is a boot loader and what is its primary purpose? Where is a boot loader found on a permanent storage device such as a hard disk What is a 2 stage boot loader? Why is 2-state boot loading used?

A bootloader, also known as a boot program or bootstrap loader, is a special operating system software that loads into the working memory of a computer after start-up. The role of a boot loader is to load an operating system from a storage device, set up a minimal environment in which the OS can run, and run the operating system's startup procedure A boot loader is found in persistent memory (ROM). A two-stage bootloader actually consists of two bootloaders after each other. The first being small with the sole purpose of loading the second one. The second one can then contain all the code needed for loading the kernel. Remember that bootloaders, and bootsectors, are only 512 bytes in size. If the bootloader, within that same 512 bytes, executed the kernel directly, it is called a Single Stage Bootloader. The problem with this, however, is that of its size. There is so little room to do alot within those 512 bytes. It will be very difficault to set up, load and execute a 32 bit kernel within a 16 bit bootloader. This does not include error handling code. This includes code for: Loading and finding 32 bit kernel, executing kernel, and error handling. Fitting all of this code within 512 bytes is impossible. Because of this, Single stage bootloaders have to load and execute a 16 bit kernel.A Multi Stage Bootloader consists of a single 512 byte bootloader (The Single Stage Loader), however it just loads and executes another loader - A Second Stage Bootloader. the Second Stage Bootloader is normally 16 bit, however it will include all of the code (listed in the previous section), and more. It will be able to load and execute a 32 bit Kernel. The reason this works is because the only 512 byte limitation is the bootloader. As long as the bootloader loads all of the sectors for the Second Stage loader in good manner, the Second Stage Loader has no limitation in size. This makes things much easier to set up for the Kernel.

Amdahl's Law

A rule stating that the performance enhancement possible with a given improvement is limited by the amount that the improved feature is used. It is a quantitative version of the law of diminishing returns. Formula: 1/S+((1-S)/N) S = serial portion, N = processing cores

Keeping in mind the various definitions of operating system, consider whether the operating system should include applications such as web browsers and mail programs. Argue both that it should and that it should not, and support your answers

An argument in favor of including popular applications with theoperating system is that if the application is embedded within theoperating system, it is likely to be better able to take advantage offeatures in the kernel and therefore have performance advantagesover an application that runs outside of the kernel. Arguments against embedding applications within the operating system typically dominate however: (1) the applications are applications - and not part of an operating system, (2) any performance benefits of running within the kernel are offset by security vulnerabilities, (3) it leads to a bloated operating system.

What is the purpose of interrupts? How does an interrupt differ from a trap? Can traps be generated intentionally by a user program? If so, for what purpose?

An interrupt is a hardware‐generated signal within the system. When caused, a handler is generated to address the source of the interrupt; control is then returned to the interrupted context and instruction. A trap on the other hand is a software‐generated interrupt. An interrupt can be used to signal the completion of an input/output operation. Traps can be generated intentionally by a user program, and it is often used to call specific operating system routines or to catch arithmetic errors whereas interrupts are sometimes not connected with any instruction. Interrupts with higher priorities are able to disrupt ones with lower priorities

Distinguish between the client-server and peer-to-peer models of distributed systems.

Client-server: With a client-server model, there is a server that is accessed through a network which is in turn accessed by clients through smart PCs like computers or smartphones. In this model, the client requests services that are provided by the server. A peer-to-peer is less strict in enforcing roles between the server and its clients. In this model, points of access are considered nodes distinguished as peers. A node is able to provide and request services from other nodes.

Define the term, direct memory access (DMA)

Direct memory access is a feature of computer systems that essentially gives permission to specific hardware subsystems to access the random-access memory, or main memory, of a computer to transmit information through I/O devices at high speeds.

Briefly describe(with at least 4 to 5 sentences for each question) the two major functions of an operating system using suitable examples for each one of the scenarios

Extended Machine: The extended machine contains an instruction set, memory organization, I/O devices and bus structures. The usage of the hardware information is abstracted in the operating system. This abstraction of details provides a program which can create, write, and execute, without the details of the working mechanisms of hardware. Resource Management: The major task of an operating system is to manage different types of hardware devices like CPU, memory, printers, timers, network interfaces etc. So that these devices are available to the users to perform input/output, storage operations. When multiple programs are running, the task of the operating system to share the processor between these programs, so that the CPU utilization is high, and no program is starved. Similarly, memory is also shared between multiple programs. Operating system must provide the memory units to these programs and in the multiplexing concepts, multiple programs can utilize the time and space resource managers. Operating system allows the users to store and retrieve data by making the input output devices active whenever the user requests.

What do you mean by LILO and GRUB?

GRUB is a boot loader which can be used for Linux, vSTA, DOS, and other operating systems while LILO is a generic boot loader for Linux. 2. Both GRUB and LILO can boot operating systems from external devices such as floppy disks and hard drives, but 3.

1. Assume you would like to access the server when you are not on-campus. What extra software do you first need to run before trying to access the server while off-campus?

If Mac, you can use the built in terminal and ssh. If you are using windows, PuTTY and PSCP are needed.

Can UNIX fork() return an error? Why or why not?

If there is insufficient storage space is available. If the system lacked the necessary resources to create another process, or the system-imposed limit on the total number of processes under execution system-wide or by a single user {CHILD_MAX} would be exceeded.

What do you understand by IRQ?

In a computer, an interrupt request (or IRQ) is a hardware signal sent to the processor that temporarily stops a running program and allows a special program, an interrupt handler, to run instead.

Study Memory hierarchy

In computer architecture, the memory hierarchy separates computer storage into a hierarchy based on response time. Since response time, complexity, and capacity are related, the levels may also be distinguished by their performance and controlling technologies.[1] Memory hierarchy affects performance in computer architectural design, algorithm predictions, and lower level programming constructs involving locality of reference.

What is a system call and how does it operate?

In computing, a system call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system

What is the purpose of the command interpreter? Why is it usually separate from the kernel?

It reads commands from the user or file and executes them through calls from the main system. A command interpreter allows users to interact with programs; however, many in this age undergo changes or are replaced by graphical user interfaces (GUI) or menu-driven interfaces. The operating system kernel represents the highest level of privilege in a modern general purpose computer. The kernel holds access to protected hardware and controls how limited resources such as running time on the CPU and physical memory pages are used by processes on the system, so command interpreters, which are often subject to alteration, are kept separate for this reason.

Linux file has three levels of security associated with it that matches the three classes of users that may access that file. What are those?

Levels of security: read, write, execute User classes: user, group. other

Explain the difference between a monolithic kernel and a microkernel.

Microkernel and monolithic kernel are two types of kernels. The difference between microkernel and monolithic kernel is that the microkernel-based systems have OS services and kernel in separate address spaces while the monolithic kernel-based system has OS services and kernel in the same address space.

Draw process state diagram.

New: when a new process is being created. Running: A process is said to be in running state when instructions are being executed. Waiting: The process is waiting for some event to occur (such as an I/O operation). Ready: The process is waiting for processor. Terminated: The process has finished execution.

Briefly(2 to 3 sentences each) discuss pass-by-value versus pass-by-reference mechanisms for passing parameters to methods

Pass by value means that a copy of the actual parameter's value is made in memory, i.e. the caller and callee have two independent variables with the same value. If the callee modifies the parameter value, the effect is not visible to the caller. Pass by reference (also called pass by address) means to pass the reference of an argument in the calling function to the corresponding formal parameter of the called function so that a copy of the address of the actual parameter is made in memory, i.e. the caller and the callee use the same variable for the parameter.

What does it mean to preempt a process?

Preemption as used with respect to operating systems means the ability of the operating system to preempt (that is, stop or pause) a currently scheduled task in favour of a higher priority task. The resource being scheduled may be the processor or I/O, among others.

How does the distinction between kernel mode and user mode function as a rudimentary form of protection (security) system?

Some instructions are only executable when the CPU is in kernel mode. Furthermore, some hardware devices utilized during instruction execution are only reachable in kernel mode. Enabling and disabling interrupts is also possible only when the CPU is in kernel mode. On the other hand, the CPU is significantly more limited in capability when running instructions in user mode, providing a form of protection from more important resources.

Explain the Role of the Linker and Loader (g++ -o -c etc.)

Source code compiled into object files designed to be loaded into any physical memory location - relocatable object file Linker combines these into single binary executable file Also brings in libraries Program resides on secondary storage as binary executable Must be brought into memory by loader to be executed

What is the difference between source code, pseudo code, and an algorithm

Source code is the actual code that can be compiled into an app and then be executed by the machine. An algorithm is a systematic logical approach used to solve problems in a computer while Pseudocode is the statement in plain English which may be translated later into a programming language (program). An algorithm is the semantic while the pseudo-code is just a syntax of the communication about solving a problem.

What is POST?

Stands for "Power On Self Test." POST (or P.O.S.T.) is a series of system checks run by computers and other electronic devices when they are turned on. On computer systems, the POST operation runs at the beginning of the boot sequence

Describe the difference between syntax and semantic errors. How do you detect them? How do you fix them?

Syntax errors occur during the parsing of input code, and are caused by grammatically incorrect statements. Semantic errors occur during the execution of the code, after it has been parsed as grammatically correct.

What is a function prototype and when is it needed

The function prototypes are used to tell the compiler about the number of arguments and about the required datatypes of a function parameter, it also tells about the return type of the function. If some function is called somewhere, but its body is not defined yet, that is defined after the current line, then it may generate problems. The compiler does not find what is the function and what is its signature. In that case, we need to function prototypes.

In operating system terminology (and not in data structure terminology) what is heap and what is stack?

The heap is an area of dynamically-allocated memory that is managed automatically by the operating system or the memory manager library. A stack is a special area of computer's memory which stores temporary variables created by a function. In stack, variables are declared, stored and initialized during runtime. It is a temporary storage memory. When the computing task is complete, the memory of the variable will be automatically erased.

Briefly describe the difference between compiling and linking phases involved in creating an executable from a C++ programˇ

The process of translating the source code into an object file is called compiling. After the compiler has created all the object files, another program is called to bundle them into an executable program file. That program is called a linker and the process of bundling them into the executable is called linking.

Why do some operating systems store the operating system in firmware, while others store it on disk?

The reason to use a firmware as storage for the operating system would be if the device cannot contain a disk or a disk is not compatible with the specific hardware.

What is the difference, if any, between the following terms: Proprietary vs. open operating system

The term open source refers to software whose source code — the medium in which programmers create and modify software — is freely available on the Internet; by contrast, the source code for proprietary commercial software is usually a closely guarded secret.

What is the purpose of the UNIX pipe command, i.e., vertical bar character |

The vertical bar character is used to represent a pipe in commands in Linux and other Unix-like operating systems. A pipe is a form of redirection that is used to send the output of one program to another program for further processing

What is virtual memory? Why is it used on most modern operating systems?

Virtual memory provides virtual address mapping between applications and hardware memory. Virtual memory provides many functions, including multitasking (multiple tasks executing at once on one CPU), allowing multiple processes to access the same shared library in memory, swapping, and others.

What is the purpose of system calls, and how do system calls relate to the OS and to the concept of dual-mode (kernelmode and usermode) operation?

When a program in user mode requires access to RAM or a hardware resource, it must ask the kernel to provide access to that resource. This is done via something called a system call. When a program makes a system call, the mode is switched from user mode to kernel mode. This is called a context switch. Then the kernel provides the resource which the program requested. After that, another context switch happens which results in change of mode from kernel mode back to user mode.

What is the difference, if any, between the following terms: Host vs. guest operating system

Whereas the host operating system is software installed on a computer to interact with the hardware, the guest operating system is software installed onto and running on the virtual machine. While the guest OS shares resources with the host OS, the two operate independently of one another. These various operating systems can run at the same time, but the host operating system must be started initially. One of the major benefits of using a guest OS is the ability to run programs and applications that don't work with the host OS.

Can UNIX exec() return an error?Why or why not?

Yes, if: The number of bytes used by the new process image's argument list and environment list is greater than the system-imposed limit of {ARG_MAX} bytes. Search permission is denied for a directory listed in the new process image file's path prefix, or the new process image file denies execution permission, or the new process image file is not a regular file and the implementation does not support execution of files of its type. A component of path or file does not name an existing file or path or file is an empty string.

How should an operating system support communication between applications? Explain your reasoning.

a) Through the file system b) Through messages passed between applications? c) Through regions of memory shared between the applications?

Define the following terms in your own language: a. Shell b. Process

a. In computing, a shell is a user interface for access to an operating system's services. In general, operating system shells use either a command-line interface or graphical user interface, depending on a computer's role and particular operation. b. In computing, a process is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity. Depending on the operating system, a process may be made up of multiple threads of execution that execute instructions concurrently.

How to use SCP Command.

cd <fileDirectoryLocation> scp <fileName.type> <server>:~/directory/<copyName>

Mention some of your favourite disk utilities and commands.

fdisk is a powerful and popular command line tool used for creating and manipulating disk partition tables. sfdisk works more like fdisk, it prints or manipulates a storage disk partition table. However, sfdisk offers extra features not available in fdisk. You can use it just as fdisk, it also supports GPT, MBR, Sun and SGI partition tables. Parted can be used for creating space for new partitions, reorganizing disk usage, and copying data to new hard disks and beyond.

Compiling C file

gcc <filename>.c -lpthread ./a.out <input if needed>

Testing Hello World in Linux (C++)

std::cout << "Hello World!" << endl;

Testing Hello World in Linux (Java)

system.out.println("Hello World!");

What are the two models of inter-process communication? What are the strengths and weaknesses of the two approaches

• Message passing- strengths: program structures better separated, dangerous operations firewalled- weaknesses: message passes more slowly, for symmetrical copy operations are to be made• Shared memory- strengths: fast and direct- weaknesses: unexpected behavior when unauthentic programs wrongly accesses the shared memorysegments


Kaugnay na mga set ng pag-aaral

Biology 1 (Biology 1610) CH.6 "A tour of the cell."

View Set

Alterations in Cardiovascular Function & Perfusion

View Set

Chapter 11: Volcanoes, Deformation, & Earthquakes

View Set

MTVR Operating the MK-Series Vehicle Under Unusual Conditions (Remote)

View Set

FIN300 Final Exam Homework Questions

View Set