P1L2 Flashcards

(11 cards)

1
Q

What is Operating System? What are the key roles of an operating system?

A

In simplest terms, an operating system(OS) is a special piece of software that abstracts and arbitrates the underlying hardware system.

An operating system is a layer of systems software that resides between hardware and applications:

1) it directly has privileged access to the underlying hardware and manipulate its state;
2) its role is to hide the hardware complexity and manage hardware on behalf of one or more applications according to some predefined policies;
3) it ensures that applications are isolated and protected from one another

The key roles of an operating system is to abstract and arbitrates the hardware systems: it hides the hardware complexity from applications and application developers and manage hardware on behalf of applications according to predefined policies and ensures that applications are isolated and protected from each other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
Which of the following are likely components of an operating system? Check all that apply:
A. File Editor 
B. Cache Memory
C. File System
D. Web browser
E. Device Driver
F. Scheduler
A

C. File System E. Device Driver F. Scheduler

Starting from the top, a file editor is likely not a part of an operating system because the users interact with it directly, and it’s not involved directly in managing hardware. Next, the file system is likely a part of an operating system. It’s directly responsible for hiding hardware complexity and for exporting a simpler, more intuitive abstractions. A file, as opposed to block of disk storage. Device drivers are also likely part of an operating system. A device driver is directly responsible for making decisions regarding the usage of the hardware devices. Cache memory is a little bit tricky. Although the operating system and the application software utilize cache memory for performance, the OS doesn’t directly manage the cache. It’s really the hardware that manages it itself. Wb browsers are also not part of aen operating system. Again, just like in the file editor case, it’s an application that users interact with and does not have direct control over underlying hardware. And finally, the scheduler. This is indeed a part of the operating system because it’s responsible for distributing the access to the processing element, the CPU, among all of the applications that share that platform.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Abstraction or Arbitration Quiz:
For the following options, indicate if they are examples of abstraction(B) or arbitration (R)
1. distributing memory between multiple processes
2. supporting different types of speakers
3. interchangeable access of hard disk or SSD

A

1 is abstraction(B) 2 and 3 are arbitration(R)

For the first option, distributing memory between processes, that’s an arbitration. This is something an operating system does as a result of its effort to manage the memory and determine how multiple processes will share. The second option, supporting different types of speakers, that’s an abstraction. It is because the operating system provides abstractions such as this one that you can plug in one set of speakers, and if they don’t work, exchange them with something else. In some cases, drivers are required, which enables an operating system to control the hardware device without knowing details about that specific hardware, so the device driver will have the knowledge of the specific actual hardware element, like the specific speaker. And along similar lines, the ability to interchangeably access different types of storage devices like hard disks or SSDs is again an example of an abstraction just like the example above. Again, because of the use of the storage abstraction that operating systems support, they can underneath feel the different types of devices and hide that from the applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can you make distinction between OS abstractions, mechanisms, policies?

A

Abstractions are the simplified view of underlying hardware systems in support of applications. Examples of abstraction include: process, thread, file, socket, memory page

Mechanisms are the operations of the above abstractions on behalf of applications so that applications can access/use hardware resources. Examples of mechanisms include: create (process/thread), schedule(process/thread), open(file), write, allocate(memory)

Policies determine how mechanisms will be used to manage the underlying hardware. e.g., maximum number of sockets that a process could access, the oder of the date to be removed (last recently used(LRS), earliest deadline first(EDF))

e.g.. OS elements: memory management example
Let’s look at an example. And, for instance, we said one of the responsibilities of the operating system is to manage resources like memory. So, we’ll look at a memory management based example.To do that, the operating system uses a memory page as an abstraction. And this abstraction corresponds to some addressable region of memory of some fixed size, for instance, 4k.The operating system also integrates a number of mechanisms to operate on that page. It can allocate that page in DRAM, and it can map that page into the address piece of the process. By doing that, it allows the process to access the actual physical memory that corresponds to the contents of that page. In fact, over time, this page may be moved across different locations in physical memory. Or, it sometimes may even be stored on disk, if we need to make room for some other content in physical memory. This last one brings us to the third element, policies. Since it is faster to access data from memory then on disk, the operating system must have some policies to decide whether the contents of this page will be stored in physical memory or copied on disk. And, a common policy that operating systems incorporate is one that decides that the pages that have been least recently used over a period of time are the ones that will no longer be in physical memory, and instead will be copied on disk. We refer to this also as swappings. So, we swap the pages. It’s no longer in physical memory, it’s in disk. The rationale for that is that pages that have not been accessed in a while, so the least recently used ones, are likely not to be as important, or likely will not even be used any time in the near future. And, that’s why we can afford to copy them on disk. The ones that have been accessed more frequently are likely more important, or likely we’re currently working on that particular part of the content, so, we will continue accessing them, and that’s why we maintain them in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the main principles in designing a good OS?

What does the principle of separation of mechanism and policy mean?

What does the principles of optimize for the common case mean?

A

The first one we call ‘separation of mechanisms and policy’. What this means is that we want to incorporate into the operating system a number of flexible mechanisms that can support a range of policies. For memory management some useful policies would include ‘least recently used’, ‘least frequently used’ or completely random. So what this means is that in the operating system we’d like to have some mechanisms to track the frequency or the time when memory location has been accessed. This will help us keep track of when a page was last used or when a page was last frequently used or we can completely ignore that information. But the bottom line is we can implement any one of these policies in terms of how that memory management is going to operate. And the reason is that in different settings, different policies make more sense.

This leads to the second principle which is ‘optimize for the common case’. What this means is that we need to understand a number of questions how the operating system, well, will be used. What it will need to provide in order to understand what the common case is. This includes understanding where it will be used, what kind of machine it will run on, how many processing elements does it have, how many cpu’s, how much memory, what kinds of devices… And we also need to understand what are the common things the end-users will do on that machine? What are the applications they will execute and also what are the requirements of that workload and how does that workload behave. We need to understand the common case and then based on that common case, pick a specific policy that makes sense and that can be supported given the underlying mechanisms and abstractions the operating system supports.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What happens during a user-kernel mode crossing?

A

attempts to perform a privileged operation when in user-mode will cause a trap. The application will be interrupted and the hardware will switch the control to the operating system at a specific location. At that point the operating system will have a chance to check what caused that trap to occur and then to verify if it should grant that access or if it should perhaps terminate the process if it was trying to perform something illegal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are some of the reasons why user-kernel mode crossing happens?

A

‘open’ to to perform access to a file, or a ‘send’ to perform access to a socket or ‘mmap’ to allocate memory,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a kernel trap? Why does it happen? What are the steps that take place during a kernel trap?

A

A trap occurs if a process attempts to do something illegal, it will transition the processing to a kernel-level trap handler to determine what action to take as a result of the trap. This exists for two reasons, one to protect the system to programmer errors, for example if a programmer accidentally accesses the memory of the hard drive, he could wipe out its contents. If a programmer invokes an instruction that doesn’t exist on the system, the application should generally not proceed. There are malicious intents as well that can be protected by traps.
First the trap will occur, for example an illegal instruction. In this case the CPU will detect that the illegal instruction was executed, and transition the kernel to the trap.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a system call?

How does it happen? What are the steps that take place during a system call?

How to make a system call?

A

A system call is a request from an application program for the operating system to perform some privileged operations on behalf of the application.

When an executing user process needs to perform some privileged operations, it makes a system call. On a system call, control is passed to the operating system, in privileged mode, and the operating system will perform the operation and return the results to the process. Executing a system call involves changing the execution context from the user process to that of the kernel, also passing arguments, whatever necessary for the system cooperation, and then jumping somewhere in the memory of the kernel so that you can go through the instruction sequence that corresponds to that system call. With the system call, control is passed to the operating system, the operating system operates in privileged mode, and it is allowed to perform whatever operation was specified in the system call. Once the system call completes, it returns the result and control back to the calling process and this again will involve changing the execution context from now the kernel mode into the user mode, passing any arguments back into the user address space, and then jumping to the exact same location in the execution of the user process where the system call was being made from.

To make a system call, an application must write arguments, save all relevant data in at a well-defined location, make the actual system call using the specific system call number. The well-defined location is necessary so that the operating system kernel, based on the system call number, can determine which, how many arguments it should retrieve and where are they, at this well-defined location.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

System calls quiz:

  1. send a signal to a process
  2. set the group identity of a process
  3. mount a file system
  4. read/write system parameters
A
  1. kill
  2. setgid
  3. mount
  4. sysctl
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Contrast the design decisions and performance tradeoffs among monolithic, modular and microkernel-based OS designs.

A

Monolithic Operating System - Every possible services such as device driver, file management or other resource that any application can require or any hardware will demand is present. Pros: everything is included, compile-time optimizations Cons: too much state/code, hard to maintain, debug or upgrade, large memory requirement, impact application performance

Modular OS - It has basic abstractions and services, various components of the OS are modular, such as device drivers, module interfaces allows everything to be dynamically added as a module. Pros: easy customization, easy maintain/upgrade, smaller footprint, less resource needs/better application performance. Cons: Indirection can impact performance, maintenance can still be an issue.

Microkernel OS - it has most basic abstractions/services, Very few operations are supported by the OS directly, such as Address Space, threads, and IPC(inter-process communication) all other applications/services such as database, file system, disk driver will run outside of os kernel at user level. Pros: very Small, Verifiable. Cons: Portability, complexity of development, cost of user/kernel crossing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly