Op System
CPU Instruction Cycle
fetch - next instruction fetched from memory decode - encoded instruction is interpreted by the CPU execute - control unit of the CPU passes the decoded information as a sequence of control signals to the relevant function units of the CPU to perform the actions required by the instruction (MMU or ALU) (store?)
Disk Management Options
first free block -> large FAT, slow load (need to defrag) best fit -> suppose the file is a document. what happens if the user wants to append the document? end of file list -> what happens when another file needs to be written while your file is still open? Also, how do you recover freed blocks? NO GOOD SOLUTION
when is a system call used
for all operations that require access to hardware beyond the CPU and a designated region on RAM must be carried out by the kernel
System Calls
functions carried out by the operating system on behalf of a running program when the program needs a system service. the vehicle (the API) through which requests for service are submitted to the kernel B/C The O/S creates abstractions of h/w resources to be used by programs. programs access these resources by making system calls to the O/S
API
high-level Application Programming Interface Three most common APIs are: Win32 API for Windows POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X) Java API for the Java virtual machine (JVM)
system call
how user mode programs obtain services from the O/S system call executes a trap command which switches the CPU to kernel mode and invokes the O/S
CPU Modes
kernel and user mode
Datapath for lw and sw
lw : data from RAM carried by system bus to MMU and registers sw is opposite
rootkit
malware that infects the bootloader so that it is loaded in privileged mode before or concurrently with the O/S typically planted by malware that manages to gain access to the CPU in kernel mode
Example of I/O Devices
mouse printers display network keyboard
Data bus or bus
multiple data wires connect a set of components and the bus can transfer as many bits as there are wires
To the calling program, is making a system call different than making any other library call?
no
user mode
non privileged mode for running non o/s code the CPU permits access to instruction that don't involve h/w access only
Bus Width
number of wires in the bus
Common Numeric Prefixes
pico 10^-12 0.000000000001 nano 10^-9 0.000000001 micro 10^-6 0.000001 milli 10^-3 0.001 Kilo 10^3 1,000 2^10 1024 Mega 10^6 1,000,000 2^20 1024^2 = 1,048,576 Giga 10^9 1,000,000,000 2^30 1024^3 = 1,073,741,824 Tera 10^12 1,000,000,000,000 2^40 1024^4 Peta 10^15 1,000,000,000,000,000 2^50 1024^5 Exa 10^18 1,000,000,000,000,000,000 2^60 1024^6
kernel mode
privileged mode for running o/s code the CPU allows access to all instructions
logical abstraction
provides a framework for discussing the logical organization of data or things eg.
What are the four main tasks of the BIOS/UEFI?
1. Performs a system check of RAM, locates basic peripherals, and and issues errors 2. Enumerates devices on the various system buses 3. Reads in sector 0 of the first boot disk 4. Executes the bootloader
How to make a system call
1. To invoke the O/S, the user code passes function parameters to the kernel through the API 2. The kernel figures out what the user's program wants 3. The kernel checks for permission 4. if permission, kernel executes a TRAP instruction to switch the CPU to kernel mode 5. kernel then transfers control of the CPU to the (trusted!) library function 6. Once the function completes, the control of the CPU is returned to the kernel that switches the CPU back to user mode before returning control to the user program
6) What is a dual-mode operating system? Your answer should include CPU modes and trapping.
A dual-mode operating system has two modes a user mode and a kernel mode. The user mode of the operating system is the non-privileged mode used for running non-operating System code. The kernel-mode is the privileged mode used for running operating system code. In kernel mode, the CPU allows access to all instructions including all hardware instructions. However, in user mode, you only have access to limited CPU instructions and some RAM but do not have access to all hardware instructions. If user-mode had access to all hardware information multiple problems could occur because processes ran could affect the overall functionality of the system. The operating system's kernel runs in kernel mode. User-mode processes use system calls to obtain services from the operating system and these system calls run Trap instructions. Trapping is the term for the process between switching from user mode into kernel mode.
5) What is meant by a memory-mapped I/O device?
A memory mapped I/O device is a Peripheral device that is mapped to a location in memory. Memory-mapped I/O devices exist so that data can be communicated between the CPU and the peripheral I/O devices and treated as regular read and writes to control the peripheral devices.
11) What is a rootkit?
A rootkit is used to gain access to a CPU in kerenel mode. It is a malware that infects the bootloader so that it is loaded in privileged mode before or concurrently with the O/S.
I/) Operations
A running program may require I/O, which may involve a file or an I/O device
3) What is a system bus? Your answer should include a discussion of the data bus and the address bus.
A system bus also called a databus is defined as multiple wires used to pass information between connecting components. Each wire is called a data wire which can transmit information one bit at a time. The system bus includes the data bus and the address bus. The data bus contains the information that will be sent between devices and the address bus contains the location for where the data will be sent.
13) What is a virtual machine?
A virtual machine is a software ran on a virtual engine to act as a virtual operating system emulating a CPU.
12) What is a virtualization engine?
A virtualization engine is basically a software that acts as a virtual hardware for the virtual machine to run on.
User Interface
Almost all operating systems have a user interface (UI). Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch
8) What is an API?
An API is an Application programming interface. An API is a document that basically is a set of functions and procedures allow.
O/S Interface Command Interpreters Examples
Bash (Linux) Terminal (MacOS and OS/X) MS-DOS, CMD (Windows)
4) Describe the system boot-up process.
CMOS/EEPROM Config. Parameters Perform POST* Perform Device Enumeration Read in Bootloader from Sector 0 of first bootable device Execute Bootloader Bootloader Loads O/S from Disk
4 Main Components of the Computer
CPU RAM / Main Memory Disks I/O Devices
Describe, in detail, the Fetch-Code-Execute Cycle
Fetch the instruction: The next instruction is fetched from memory. The program counter keeps track of where the next instruction resides.Decode the instruction: The encoded instruction is interpreted by the control unit and the control unit determines which subsystem of the CPU it targets (ALU, MMU).Execute the instruction: The control unit of the CPU passes the decoded information as a sequence of control signals to the relevant subsystem of the CPU to perform the actions required by the instruction
User Operating System Interface - GUI
Graphical User Interface User-friendly desktop metaphor interface Usually mouse, keyboard, and monitor Icons represent files, programs, actions, etc Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder) Invented at Xerox PARC Many systems now include both CLI and GUI interfaces Microsoft Windows is GUI with CLI "command" shell Apple Mac OS X is "Aqua" GUI interface with UNIX kernel underneath and shells available Unix and Linux have CLI with optional GUI interfaces (CDE, KDE, GNOME)
conceptual abstraction
Hides complexities of a real system not important in a particular context eg. knowing about an elevator it works by levers and pulleys and strong cables and buttons but not know the actual technical information behind it
What does the program counter do?
Holds the address of the next instruction to be fetched
3) What is POSIX? Why is it important?
POSIX is a standard for creating compatibility between O/S systems through defining a set of common API functions
"TRAPping" into the kernel
Switching to kernel mode
1) What is a system call? How is it different from a regular library function call?
System calls are used for programs to access abstracted hardware resources. System calls are functions executed by a program when the program needs to access a hardware service. System calls are different then library function calls because they require a switch into kernel mode which inherently makes them more costly to complete.
What is the BIOS/UEFI? What do they do?
The BIOS is a program stored in a hardware on a chip all by itself that handles bootup. It is executed when starting up a computer. It executes in ROM. Even if the hard drive is removed, the program stays on.
Both users claim that the CPU is working on her problem. How can this be? There is only 1 CPU.
The CPU's time is being shared. The O/S is responsible for abstracting a single CPU into as many "virtual" CPUs (called processes). The O/S then manages how each process accesses the 1 physical CPU.
A software developer is working on a computer with 1GB of RAM. The programmer is developing a memory hungry video editing application. The first line of her code attempts to allocate 1.5GB of RAM to hold the video. The allocation succeeds.* How is this possible?
The MMU has given her program a virtual memory space and is paging out to disk the portion of RAM beyond 1GB
File System manipulation
The file system is of particular interest. Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.
Protection and Security
The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other Protection - involves ensuring that all access to system resources is controlled Security - of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts
1) Describe the role of a modern operating system. (your answer should include hardware abstraction and resource allocation and management). Provide examples.
The primary role of an operating system is too abstract out and manage the hardware resources of a computer.
Program execution
The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error)
Accounting
To keep track of which users use how much and what kinds of computer resources
9) Describe the process of making a system call. Your answer should include the calling program, the O/S API, the steps carried out by the kernel, the CPU's operating mode, etc.
To make a system call the steps are to pass function parameters to the kernel through the API. Next check for proper permissions. Next Execute a TRAP to switch into kernel mode. Call the appropriate library functions to complete the task. Finally switch back into user mode.
Touchscreen Interfaces
Touchscreen devices require new interfaces Mouse not possible or not desired Actions and selection based on gestures Virtual keyboard for text entry Voice commands
operating system services
User Interface Program Execution, I/O Operations, File-system manipulation, Communications, Error detection, resource allocation, accounting, Protection/Security
Resource Allocation
When multiple users or multiple jobs running concurrently, resources must be allocated to each of them Many types of resources - CPU cycles, main memory, file storage, I/O devices.
Difference between a system call and a normal library function call
With a system call, the CPU is transferred to kernel mode
hard disk
a collection of magnetic platters whose surface can be organized into a sequence of magnetized (1) or de-magnetized (0) compartments, each representing 1 bit of information
interrupt
a signal sent to a CPU indicating an event that needs immediate attention interrupts are "raised"
kernel
core process of an operating system
7) The BASH shell is an example of a Graphical User Interface, or GUI a batch interface an O/S performance monitor a command-line interface, or CLI a) a Graphical User Interface, or GUI b) a batch interface c) an O/S performance monitor d) a command-line interface, or CLI
d)
Chapter 2
dwnqln
synchronization
the hardware's state can't be changed without the knowledge of the O/S
Virtual Machine
the result of having installed an O/S on hardware emulated by a VE
O/S Interface Graphical User Interfaces Examples
KDE (Linux) GNOME (Linux) Aqua (MacOS and OS/X) iOS (iOS) Windows (Windows)
O/S Resource & Performance Monitors
O/S Services are varied and complex Most O/S es provide a utility to monitor system performance Eg. MacOS / OS/X - Activity Monitor Windows (prior to Windows 10) - Process Monitor Windows 10 - Resource Monitor iOS - Not provided with the O/S Linux - top
Error Detection
OS needs to be constantly aware of possible errors May occur in the CPU and memory hardware, in I/O devices, in user program For each type of error, OS should take the appropriate action to ensure correct and consistent computing Debugging facilities can greatly enhance the user's and programmer's abilities to efficiently use the system
POSIX
Portable Operating System Interface Standard (IEEE 1003) for maintaining compatibility between operating systems by defining a set of common application programming interface (API) functions shared by POSIX compliant OSes A program written with only POSIX-compliant system calls should compile on Windows, Linux, OS/X and any other POSIX compliant O/S
4 Main Areas of concern of the Operating System
Process Control (CPU Abstraction) Memory Management File Systems Management of I/O Devices
Types of System Calls
Process control - create process, terminate process ; end, abort ; load, execute ; get process attributes, set process attributes ; wait for time ; wait event ; signal event Memory Control - allocate and free memory File management - create file, delete file ; open, close file ; read, write, reposition ; get and set file attributes Device management - request device, release device ; read, write, reposition ; get device attributes, set device attributes ; logically attach or detach devices Information maintenance - get time or date, set time or date ; get system data, set system data ; get and set process, file, or device attributes Communications - create, delete communication connection ; send, receive messages Protection - Control access to resources ; Get and set permissions ; Allow and deny user access
Communications
Processes may exchange information, on the same computer or between computers over a network Communications may be via shared memory or through message passing (packets moved by the OS)
What is not part of operating system
Shell Graphical User Interface Compilers Web Browsers Utilities Most (if not all) user executable programs
CLI or command interpreter
allows direct command entry Usually just a regular program called a shell There may be a choice of shells on a given system Primarily fetches a command from user and executes it Sometimes commands built-in, sometimes just names of programs If the latter, adding new features doesn't require shell modification
Data Wire
an electric wire used to pass information between two or more devices one bit at a time has voltage of 1 or 0
6) Who is the primary "customer" or an operating system? (to whom does an O/S primarily offer its services?) users programs and programmers the kernel I/O devices. a) users b) programs and programmers c) the kernel d) I/O devices
b)
10) For which of these tasks must a program invoke the services of the O/S? sorting a list of 100 names printing "Hello World" to the screen having the user enter her age finding the first 100 prime numbers using the camera to take a selfie a)sorting a list of 100 names b)printing "Hello World" to the screen c)having the user enter her age d)finding the first 100 prime numbers e)using the camera to take a selfie
b) e)
what does the kernel do?
responsible for the scheduling and management of processes the management of memory the implementation of a file system
operating system
software that controls the execution of computer programs; acts as an intermediary between the hardware and the software applications
Virtualization Engine
software that emulates the physical hardware of an entire computer system
interrupt service routine, ISR
special block of code that runs when the interrupt is called Eg. system timers, disk I/O, power-off signals, data ready (from serial, USB or Ethernet), keyboard key pressed once done the interrupt has been "handled" or "serviced"
