CS3451 OS unit 5 notes
CS3451 OS unit 5 notes
Benefits:
1. There is no overlap amongst memory as each Virtual Memory has its own memory space.
• All non-privileged instructions run natively on the hardware, providing the same To U performance for
guests as native applications. Privileged instructions create extra overhead, however, causing the guest to run
more slowly than it would natively.
• In addition, the CPU is being multi-programmed among many virtual machines, which can further slow
down the virtual machines in unpredictable ways.
• Any privileged action by guest OS traps to VMM, emulated by VMM. Example: set IDT, set CR3, access
hardware. Sensitive data structures like IDT must be managed by VMM, not guest OS.
• Problems with trap and emulate,
1) Guest OS may realize it is running at lower privilege level.
• Type 0 hypervisor is built with the minimum software components required to fully virtualize guest OSS
and control information flow between guest OSs. Type 0 hypervisors is a hardware-based solutions that
provide support for virtual machine creation and management via firmware.
• The VMM itself is encoded in the firmware and loaded at boot time. Guest image site is loaded in each
partition. "Partitions" and "domains" are other names of type 0 Hypervisor.
• The feature set of a type 0 hypervisor tends to be smaller than those of the other types because it is
implemented in hardware. For example, a system might be split into five virtual systems, each with
dedicated CPUs, memory and I/O devices.
• If I/O device are less, then they are not allocate to guest. Sometimes VMM implements a control partition
running daemons that other guests communicate with for shared I/O.
Type 1 Hypervisor
• Type 1 hypervisor is software that runs directly on a given hardware platform. A "guest" operating system
thus runs at the second level above the hardware.
• Type 1 VMs have no host operating system because they are installed on a bare system. An operating
system running on a Type 1 VM is a full virtualization because it is a complete simulation of the hardware
that it is running on.
• Type 1 hypervisor is also called a native or bare-metal hypervisor that is installed directly on the hardware,
which splits the hardware into several virtual machines where we can install guest operating systems.
• Virtual machine management software helps to manage this hypervisor, which allows guest OSes to be
moved automatically between physical servers based on current resources requirements.
• It is completely independent from the operating system.
• The hypervisor is small as its main task is sharing resources between different operating systems.
• A major advantage is that any problems in one virtual machine or guest operating system do not affect the
other guest operating systems running on the hypervisor.
Type 2 Hypervisor
• This is also known as Hosted Hypervisor.
• In this case, the hypervisor is installed on an operating system and then supports to other operating systems
above it.
• It is completely dependent on host operating system for its operations. Fig. 7.4.2 shows type 2 hypervisor.
(See Fig. 7.4.2 on next page.)
• While having a base operating system allows better specification of policies, any problems in the base
operating system affects the entire system as well even if the hypervisor running above the base OS is
secure.
• Type 2 hypervisors don't support over/dynamic allocation of RAM, so care is required when allocating
resources to virtual machines.
• This is why we call type 2 hypervisors hosted hypervisors. As opposed to type 1 hypervisors that run
directly on the hardware, hosted hypervisors have one software layer underneath. What we have in this case
is:
1. A physical machine.
2. An operating system installed on the hardware (Windows, Linux, MacOS).
3. A type 2 hypervisor software within that operating system.
4. The actual instances of guest virtual machines.
• Type 2 hypervisors are typically found in environments with a small number of servers. Type 2
hypervisors are convenient for testing new software and research br projects.
Paravirtualization
• Paravirtualization is a type of virtualization in which guest operating system (OS) is recompiled, installed
inside a Virtual Machine (VM), and operated on top of a hypervisor program running on the host OS.
• Para-virtualization refers to communication between the guest OS and the hypervisor to improve
performance and efficiency.
• Para-virtualization involves modifying the OS kernel to replace non-virtualizable instructions with hyper-
calls that communicate directly with the virtualization Jeaug layer hypervisor.
• The hypervisor also provides hyper-call interfaces for other critical kernel operations such as memory
management, interrupt handling and time keeping.
• Fig. 7.4.3 shows para-virtualization architecture.
• In Para-virtualization, the virtual machine does not necessarily simulate hardware, but instead offers a
special API that can only be used by modifying the "guest" OS. This system call to the hypervisor is called a
"hypercall" in Xen.
• Xen is an open source para-virtualization solution that requires modifications to the guest operating
systems but achieves near native performance by collaborating with the hypervisor.
• Microsoft Virtual PC is a para-virtualization virtual machine approach. User-mode Linux (UML) is another
para-virtualization solution that is open source.
• Each guest operating system executes as a process of the host operating system. Cooperative Linux, is a
virtualization solution that allows two operating systems to cooperatively share the underlying hardware.
• Linux-V server is an operating system-level virtualization solution for GNU/Linux systems with secure
isolation of independent guest servers.
• The Linux KVM is virtualization technology that has been integrated into the mainline Linux kernel. Runs
as a single kernel loadable module, a Linux kernel running on virtualization-capable hardware is able to act
as a hypervisor and support unmodified Linux and Windows guest operating systems.
• Para-virtualization shares the process with the guest operating system.
Problems with para-virtualization
1. Para-virtualized systems won't run on native hardware.
2. There are many different para-virtualization systems that use different I commands, etc.
• The main difference between full virtualization and paravirtualization in Cloud is that full virtualization
allows multiple guest operating systems to execute on a host operating system independently while
paravirtualization allows multiple guest operating systems to run on host operating systems while
communicating.
• Steps:
1. The source VMM establishes a connection with the target VMM.
2. The target creates a new guest by creating a new VCPU.
3. The source sends all read-only guest memory pages to the target.
4. The source sends all read-write pages to the target, marking them as clean.
5. The source repeats step 4, as during that step some pages were probably modified by the guest and are
now dirty.
6.When cycle of steps 4 and 5 becomes very short, source VMM freezes guest, sends VCPU's final state,
sends other state details, sends final dirty pages, and tells target to start running the guest.
• Once target acknowledges that guest running, source terminates guest.
5.6 Mobile OS: Android AU: May-22
• Android is an open source mobile OS developed by the Open Handset Alliance, to led by Google.
• Android is a software stack for mobile devices that includes an operating system, middleware and key
applications.
Android Architecture
Fig. 7.6.1 shows Android software stack. Each layer of the stack and the corresponding elements within each
layer are tightly integrated and carefully tuned to provide the optimal application development and execution
environment for mobile devices. (See Fig. 7.6.1 on next page.)
• Android provides a set of core applications:
1. Email client
2. SMS program
3. Calendar
4. Maps
5. Browser
App framework
• Used for enabling and simplifying the reuse of components
1. Developers have full access to the same framework APIs used by the core applications.
2. Users are allowed to replace components.
• App Framework features are as follows:
Libraries
• Libraries include a set of C/C++ libraries used by components of the Android system. It is exposed to
developers through the Android application framework
Runtime
• Android run-time system provides core set of class libraries to ensure smooth platform for developers. With
these libraries developers can easily import required libraries into their applications without doing any hard
coding in applications.
Dalvik virtual machine
• Dalvik is a purpose built virtual machine designed specifically for android which was developed by Dan
Bornstein and his team. Strictly it was developed for mobile devices. While developing Dalvik Virtual
Machine Dan Bornstein and his team realize the constraints specific to mobile environment which is not
going to change in future at least, like battery life, processing power and many more. So they optimized the
dalvik virtual machine. Dalvik virtual machine uses register based architecture. With this architecture dalvik
virtual machine has few advantages over java virtual machine such as:
1. Dalvik uses its own 16 bit instruction set than java 8 bit stack instructions, which reduce the dalvik
instruction count and raised its interpreter speed.
2. Dalvik use less space, which means an uncompressed .dex file is smaller in size(few bytes) than
compressed java archive file(.jar file).
• An open source software stack that includes operating system. Linux operating system kernel that provides
low level interface with the hardware, memory management and process control.
• Middleware: A run time to execute Android applications including virtual machine and core libraries.
Important blocks in Android":
1. Activity manager: Manages the activity life cycle of applications
2. Content providers: Manage the data sharing between applications
• The iOS Architecture is layered. At the highest level, iOS acts as an intermediary between the underlying
hardware and the apps you create.
• Apps do not talk to the underlying hardware directly. Instead, they communicate with the hardware through
a set of well-defined system interfaces. These interfaces make it easy to write apps that work consistently on
devices having different hardware capabilities.
• The Cocoa Touch layer contains key frameworks for building iOS apps. These frameworks define the
appearance of your app. They also provide the basic app infrastructure and support for key technologies such
as multitasking, touch-based input, push notifications and many high-level system services.
• High-Level features of Cocoa touch layers are AirDrop, Multitasking, Auto Layout, Storyboards and Local
Notifications And Apple Push Notification Service.
• Cocoa touch layer contains following frameworks for iPhone app development:
a. UIKit framework
b. Map kit framework
c. Push notification service.
d. Message UI framework noise
e. Address book UI framework
f. Game kit framework
g. iAd framework
h. Event kit UI framework
i. Accounts framework
j. Twitter framework
• The Media layer contains the graphics, audio and video technologies you use to implement multimedia
experiences in your apps. The technologies in this layer make it easy for you to build apps that look and
sound great.
• The superblock is the key to maintaining the file system. It is an 8 kB block of disk space that maintains the
current status of the file system. Because of its importance, a copy is maintained in memory and at each
cylinder group within the file system.
• The copy in main memory is updated as events transpire. The update daemon is the actual process that calls
on the kernel to flush the cached superblocks, modified inode and cached data blocks to disk.
• Usually Linux system assumes all file systems are read and writable.
1. ODEX FILE
• In Android file system, applications come in packages with the extension .apk. These application packages
or APKs contain certain .odex files whose supposed function is to save space.
• These 'odex' files are actually collections of parts of an application that are optimized before booting.
Doing so speeds up the boot process, as it preloads part of an application.
• On the other hand, it also makes hacking those applications difficult because a part of the coding has
already been extracted to another location before execution.
2. DEODEX
• Deodexing is basically repackaging of these APKs in a certain way, such that they are reassembled into
classes.dex files. All pieces of an application package are put fo together back in one place.
• Deodexed ROMs (or APKs) have all their application packages put back together in one place, allowing for
easy modification such as theming. Since no pieces of code are coming from any external location, custom
ROMS or APKs are always deodexed to ensure integrity.
7.8.1 SQLite