0% found this document useful (0 votes)
9 views

CS3451 OS unit 5 notes

The document provides an overview of virtual machines (VMs) and mobile operating systems, detailing their architecture, benefits, and disadvantages. It discusses the history of virtualization, types of hypervisors (Type 0, Type 1, Type 2), and techniques such as trap-and-emulate, binary translation, and paravirtualization. Additionally, it covers virtualization's impact on operating system components, including CPU scheduling and memory management.

Uploaded by

udhayaveena a
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

CS3451 OS unit 5 notes

The document provides an overview of virtual machines (VMs) and mobile operating systems, detailing their architecture, benefits, and disadvantages. It discusses the history of virtualization, types of hypervisors (Type 0, Type 1, Type 2), and techniques such as trap-and-emulate, binary translation, and paravirtualization. Additionally, it covers virtualization's impact on operating system components, including CPU scheduling and memory management.

Uploaded by

udhayaveena a
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Department of Information Technology

(An Autonomous Institution)

UNIT V: Virtual Machines and Mobile OS


5.1 Virtual Machines
• Virtual Machine (VM) is virtual environment that functions as a virtual computer system with its own
CPU, memory, network interface, and storage, created on a physical hardware system.
• A Virtual machine is a software construct that mimics the characteristics of a physical server.
• A virtual Machine (VM) is a software program or operating system that not only exhibits the behavior of a
separate computer, but is also capable of performing tasks such as running applications and programs like a
separate computer.
• In a pure virtual machine architecture the operating system gives each process the illusion that it is the only
process on the machine. The user writes an application as if only its code were running on the system.
• Each user interacts with the computer by typing commands to the virtual machine on a virtual system
console and receiving results back from the machine as soon as they are computed.
• Each user directs the virtual machine to perform different commands. These commands are then executed
on the physical machine in a multiprogramming environments.
• Virtualization is an abstraction layer that decouples the physical hardware from the operating system to
deliver greater IT resource utilization and flexibility.
• It allows multiple virtual machines, with heterogeneous operating systems to run in isolation, side-by-side
on the same physical machine..
Fig. 7.1.1 shows virtual machine.

Benefits:
1. There is no overlap amongst memory as each Virtual Memory has its own memory space.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


2. Virtual machines are completely isolated from the host machine and other virtual machines.
3. Data does not leak across virtual machines.
4. Can use multiple operating system environments on the same computer
5. The cost reduction is possible using small virtual servers on a more powerful single server.
Disadvantages :
1. Virtual machines are less efficient than real machines because they access the hardware indirectly.
2. A virtual machine can be infected with the weaknesses of the host machine
3. Difficulty in direct access to hardware, for example, specific cards or USB devices
4. Great use of disk space, since it takes all the files for each operating system installed on each virtual
machine.
5.2 History
• IBM announced its first official VM product, VM/370, on August 2, 1972 for the System/370.
Virtualization was provided by the IBM VM operating system. IBM VM/370 divided a mainframe into
multiple virtual machines, each running its own operating system.
• Disk system were issued with the VM technique. Assume the actual machine only el has three disk drives
but has to host eight virtual machines. It was obvious that it could not allocate a hard drive to each virtual
computer. The solution was to create virtual disks, which were referred to as a minidisks in IBM VM OS.
• Except for size, the minidisks were identified to the systems hard disks. The system implemented each
minidisk by allocating as many tracks on the physical disks as the minidisk needed.
• VM/370 is an operating system that gives multiple users access to a computer by means of keyboard and
display terminals for time sharing, system testing, production and conversion. VM/370 manages the
resources of a computer so that every user, local or remote, appears to have a complete replica of a System
370 including input output (I/O) devices.
• Each user of VM/370 can select a different operating system, if desired, because different operating I
systems can run concurrently in different virtual machines.
Benefits and Features
• Virtual machines help organizations reduce unnecessary hardware machines such
• Flexibility Virtual machines enable organizations to run multiple operating systems simultaneously.
• Easy to backup and clone.
• Major advantage of virtual machines in production data-center use is system consolidation, which involves
taking two or more separate systems and running them in virtual machines on one system.
• Saves space, time and management costs
• Support for legacy applications
• Simplify reduce downtime.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


5.3 Building Blocks
Trap-and-Emulate
• Problem with VMM is that, guest OS expects to have unrestricted access to hardware, runs privileged
instructions, unlike user processes. But one guest cannot Man get access, must be isolated from other guests.
• All CPUs have multiple privilege levels. There is ring 0,1,2,3 in x86 CPUs. Normally, user process in ring
3, OS in ring 0. Privileged instructions only run in vino ring 0. Now, user process in ring 3, VMM/host OS in
ring 0. So guest OS must be protected from guest apps. But not fully privileged like host OS/VMM. It is run
in ring 1.
• Trap and emulate VMM: Guest OS runs at lower privilege level than VMM, traps to VMM for privileged
operation.
• When the kernel in the guest attempts to execute a privileged instruction, that is an error because the
system is in user mode and causes a trap to the VMM in the real machine. The VMM gains control and
executes the action that was attempted by the guest kernel on the part of the guest. It then returns control to
the virtual machine. This is called the trap-and-emulate method.
• Fig. 7.3.1 shows trap-and-emulate method.

• 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.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


2) Some x86 instructions which change hardware state, run in both privileged and
• These problems occurs because OSes not developed to run at a lower privilege level and instruction set
architecture of x86 is not easily virtualizable.
Binary Translation
• Binary translation could be static or dynamic. Static binary translation means using ewoll a processor to
translate an image from an architecture to another before execution. In dynamic binary translation individual
instructions or groups of instructions are on the fly translated and the translation is cached to allow for reuse
in iterations without repeated translation.
• To be more precise, a segment of the original code is first executed in an interpreted mode and collected as
a segment. It is determined if the code has been execute at least N times, if so, if not already translated it is
translated and it is executed and from now the translated code will be executed.
• In binary translation the virtualization layer sits at CPU privilege level 0 (most privileged). The guest O/S
system were supposed to run on level 0, but since virtual layer occupies that level, it moves guest O/S
execution at privilege level 1 and leaves user applications at level 3 as it supposed to be.
• The non-virtualizable kernel code of the guest O/S is translated by virtual layer into new sequences of
instructions that have the intended effect on virtual hardware, while user level code is directly executed on
the CPU for high performance. The benefit of this approach is that the O/S is fully abstracted from the
underlying hardware thus it doesn't require any modification.
Hardware Assisted
• In hardware assisted virtualization the virtual layer sits in a new root mode privilege level under level 0.
Guest O/S privileged and sensitive calls are set to sibo auto trap to the hypervisor while user request are
executed directly to the CPU for high performance.
• Hardware assisted virtualization requires a compatible CPU like Intel VT-x and AMD's AMD-V to work.
• This technique is not performing as expected because of the high overhead between guests O/S-to-
hypervisor transition.
• I/O is another area improved by hardware assistance. Consider that the standard DMA controller accepts a
target memory address and a source I/O device and transfers data between the two without OS action.
Without hardware assistance, a but guest might try to set up DMA transfer that affects the memory of the
VMM or other guests.
5.4 Types of Virtual Machines and their Implementations
• In computing, a hypervisor is a virtualization platform that allows multiple operating systems to run on a
host computer at the same time. The term usually refers to an implementation using full virtualization.
• A hypervisor is a software layer installed on the physical hardware, which allows splitting the physical
machine into many virtual machines. This allows multiple and operating systems to be run simultaneously
on the same physical hardware.
• The operating system installed on the virtual machine is called a guest OS, and is sometimes also called an
instance. The hardware the hypervisor runs on is called the host machine.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


• A hypervisor management console, which is also called a virtual machine manager (VMM), is computer
software that enables easy management of virtual machines.
• Hypervisors are currently classified in two types: type 1 and type 2.
Type 0 Hypervisor
Fig. 7.4.1 shows type 0 hypervisor.

• 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.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)

• 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.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)

• 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.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)

• 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.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


Difference between Type 1 and Types 2 Hypervisor

5.5 Virtualization and Operating-System Components


• Operating system aspects of virtualization are management, I/O storage and unique VM migration feature.
• Following features are implemented by using virtualization:
a) How do VMMS schedule CPU use when guests believe they have dedicated CPUs?
b) How can memory management work when many guests require large amounts of memory?
CPU Scheduling
• After virtualization, single CPU system act like multiprocessor. Here one or more. virtual CPUs per guest is
created. Generally VMM has one or more physical CPUs and number of threads to run on them.
• The VMM has a number of physical CPUs available and a number of threads to oys run on those CPUs,
then threads can be called as VMM threads or guest threads. Guests are configured with a certain number of
virtual CPUs at creation time and that number can be adjusted throughout the life of the virtual machine.
• When enough CPUs for all guests, VMM can allocate dedicated CPUs, each guest much like native
operating system managing its CPUs.
• Usually not enough CPUs are available, then VMM can use standard scheduling algorithms to put threads
on CPUs and add fairness aspect while allocating. Cycle stealing by VMM and over subscription of CPUs
means guests do not get CPU cycles they expect.
• Some VMMS provide application to run in each guest to fix time-of-day and provide other integration
features.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


Memory Management
• Each virtual machine consumes memory based on its configured size, plus additional overhead memory for
virtualization. In virtualized environments, there are more users of memory, leading to more pressure on
memory use.
• Sometime, the total memory allocated to guests exceeds the amount that physically exists in the system.
The extra need for efficient memory use is not lost on the implementers of VMMS, who take extensive
measures to ensure the optimal use of memory.
• Suppose, VMware ESX guests have a configured amount of physical memory, then ESX uses three
memory management methods.
a) Double-paging, in which the guest page table indicates a page is in a physical frame but the VMM moves
some of those pages to backing store.
b) Install a pseudo-device driver in each guest.
• Balloon memory manager communicates with VMM and is told to allocate or de-allocate memory to
decrease or increase physical memory use of guest, causing guest OS to free or have more memory
available.
c) De-duplication by VMM determining if same page loaded more than once, memory mapping the same
page into multiple guests.
• Since hypervisor manages page sharing, the virtual machine operating systems are unaware of what is
happening in the physical system.
• Virtual Memory Ballooning is a computer memory reclamation technique used by a hypervisor to allow the
physical host system to retrieve unused memory from play certain guest Virtual Machines (VMs) and share it
with others. U
• Memory ballooning allows the total amount of RAM required by guest VMs to exceed the amount of
physical RAM available on the host. When the host system runs low on physical RAM resources, memory
ballooning allocates it selectively to VMs.
• If a VM only uses a portion of the memory that it was allocated, the ballooning technique makes it
available for the host to use.
• For example, if all the VMs on a host are allocated 8 GB of memory, some of the VMs will only use half
the allotted share. Meanwhile, one VM might need 12 GB of memory for an intensive process.
• Memory ballooning allows the host to borrow that unused memory and allocate it to the VMs with higher
memory demand.
• The guest operating system runs inside the VM, which is allocated a portion of aah memory. Therefore, the
guest OS is unaware of the total memory available.
• Memory ballooning makes the guest operating system aware of the host's memory shortage.
• Virtualization providers such as VMware enable memory ballooning. VMware memory ballooning,
Microsoft Hyper-V dynamic memory, and the open source KVM balloon process are similar in concept.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


• The host uses balloon drivers running on the VMs to determine how much memory it can take back from
an under-utilizing VM. Balloon drivers must be P M installed on any VM that participates in the memory
ballooning technique.
• Balloon drivers get the target balloon size from the hypervisor and then inflate by allocating the proper
number of guest physical pages within the VM. This process is known as inflating the balloon; the process of
releasing the available pages is known as deflating the balloon.
Input-Output Management
• I/O management is easy for VMM because I/O has lot of variation. For example, leib OS device-driver
mechanism provides a uniform interface to the OS whatever the I/O device. Device-driver interfaces are
designed to allow third-party hardware manufacturers to provide device drivers connecting their devices to
the operating system.
• Virtualization takes advantage of dynamically loaded and unloaded of device driver by providing specific
virtualized devices to guest operating systems.
• But overall I/O is complicated for VMMS, because
a) Many short paths for I/O in standard OSes for improved performance.
b) Less hypervisor needs to do for I/O for guests, the better.
c) Possibilities include direct device access, DMA pass-through, direct interrupt delivery.
• Hardware support needed for all above cases.
• With virtualization, each guest needs at least one IP address for communication. 8 So server running a
VMM may have dozens of addresses and the VMM acts as a virtual switch to route the network packets to
the addressed guests.
• Networking also complex as VMM and guests all need network access. VMM can bridge guest to network
allowing direct access and provide Network Address Translation (NAT).
• NAT address local to machine on which guest is running, VMM provides address translation to guest to
hide its address.
Storage Management
• Both boot disk and general data access need be provided by VMM. Virtualized environments need to
approach storage management differently than do native operating systems.
• Solution is based on the type of hypervisor. In type 1 hypervisor, storage guest root disks and configuration
information within file system provided by VMM as a disk image. Type 2 hypervisor store as files in file
system provided by host OS.
• Guests sometimes need more disk space than is available in their root disk image. VMMs provide a
mechanism to capture a physical system as it is currently configured and convert it to a guest that the VMM
can manage and run.
a) Physical-to-virtual (P-to-V) convert native disk blocks into VMM format.
b) Virtual-to-physical (V-to-P) convert from virtual format to native or disk format.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


• VMM also needs to provide access to network attached storage and other disk images, disk partitions, disks
etc.
Live Migration
• Live migration provides the ability to move a running virtual machine between physical hosts with no
interruption to service. The virtual machine remains powered on and user applications continue to run while
the virtual machine is relocated to a new physical host. In the background, the virtual machine's RAM is
copied from the source host to the destination host. Storage and network connectivity are not altered.
• Taking advantage of VMM features leads to new functionality not found on general operating systems such
as live migration. Running guest can be moved between systems, without interrupting user access to the
guest or its apps.
• Fig. 7.5.1 shows live migration of guest between servers.

• 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.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


• It is based on Linux 2.6 kernel.
• Android is an open source operating system, created by Google specifically for use on mobile devices (i.e.
cell phones and tablets)
• It can be programmed in C/C++ but most app development is done in Java. It supports Bluetooth, Wi-Fi
and 3G and 4G networking.

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

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


6. Contacts
7. Etc.
• All applications are written using the Java language.

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:

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)

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

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


3. Telephony manager: Manages all voice calls. We use telephony manager if we want to access voice calls
in our application.
4. Location manager: Location management, using GPS or cell tower
5. Resource manager: Manage the various types of resources we use in our application.
Android SDK features
The Android SDK includes,
1. The Android APIs.
2. The core of the SDK.
3. Development tools.
4. No licensing, distributions, or development fees or release approval processes.
5. GSM, EDGE, and 3G networks for telephony and data transfer.
6. Full multimedia hardware control.
7. APIs for using sensor hardware including accelerometer and the compass.
8. APIs for location based services.
Application framework
1. Android offers developers the ability to build rich and innovative applications.
2. Developers have full access to the same framework APIs used by the core applications.
3. Underlying all applications is a set of services, including Views.
4. It can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable
web browser.
• Content providers enable applications to access data from other applications (such as Contacts), or to share
their own data.
• A resource manager provides access to non-code resources such as localized strings, graphics and layout
files.
• A notification manager enables all applications to display custom alerts in the status bar.
• An activity manager manages the lifecycle of applications and provides a common navigation backstack.
Libraries used in Android
• A set of C/C++ libraries used by various components of the Android system.
• System C library: Tuned for embedded Linux-based devices.
• Media Libraries: Based on Packet Video's OpenCORE; the libraries support playback and recording of
many popular audio and video formats, as well as static image files.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


• Surface Manager: Manages access to the display subsystem and seamlessly composites 2D and 3D graphic
layers from multiple applications.
• LibWebCore: A modern web browser engine which powers both the Android browser and an embeddable
web view.
• SGL/ 3D libraries: SGL is underlying 2D graphics engine.
• SQLite: A powerful and lightweight relational database engine available to all applications.
Android run-time
• Android includes a set of core libraries that most of the functionality available in the core libraries of the
Java programming language.
• Every Android app runs in its own process with its own instance of the Dalvik virtual machine. The Dalvik
VM executes files in the Dalvik Executable (.dex) format:
Slow Android apps
1. By default on Android, all work is done in a single thread, the "main application" thread. If a component
of the work takes a long time, the rest of the work will be "blocked". For example, a long time to access data
across the network prevents responding to any GUI events.
2. In the Android OS, if a GUI doesn't respond to an input event in five seconds, then it is considered
unresponsive and the OS will try to kill it.
Android thread design
1. Only perform GUI actions on main application thread. Spawn separate threads to perform data-intensive
or slow actions. Make these threads asynchronous.
2. Main thread does not have to wait for/check on other threads. Instead, those threads run as they need to
and report back to the original thread. Any changes made to the UI should go through the UI thread.
Comparison of Android OS VS iPhone OS Features

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


Android applications
a.Android applications get distributed in a .apk file. APK stands for "Android board as Package". It is simply
a zip file that has a particular file structure. An APKcontains:
1. The Android Manifest file (an XML file with lots of metadata).
2. A Resource bundle containing sounds, graphics, etc.
3. The Dalvik classes that make up user application.
Android Benefits
1. An open and free development platform. Handset makers can use it without royalty and customize to their
hearts content.
2. Component-based architecture: Lots of default components can be replaced straightforwardly.
Proponents of Android point to the following benefits:
a. Lots of services location, sql, maps, web, etc.
b. Well managed applications; isolated from each other to protect data and provide
c. Operating system can quit programs as needed to ensure good performance on mobile devices.
d. Portability: To support a new device, a company has to port the virtual machine; Android apps (Dalvik)
then execute on the new device with little to no modification.
Zygote
• Android uses a concept called the Zygote to enable both sharing of code across VM instances and to
provide fast startup time of new VM instances.
• Zygote is a daemon process that provides efficient memory usage and less time overhead when Android
runs multiple application. Zygote is the parent of all application processes.
• The Zygote is a VM process that starts at system boot time. When the Zygote process starts, it initializes a
Dalvik VM, which preloads and preinitializes core library classes.
• Generally, these core library classes are read-only and are therefore a good candidate for preloading and
sharing across processes.
• Once the Zygote has initialized, it will sit and wait for socket requests coming from the runtime process
indicating that it should fork new VM instances based on the Zygote VM instance.
• Cold starting virtual machines notoriously takes a long time and can be an impediment to isolating each
application in its own VM. By spawning new VM processes from the Zygote, the startup time is minimized.
• Additional memory need not be allocated for copies of these classes when a new DVM is forked from the
Zygote DVM.
5.7 iOS Technology
• iOS is the operating system that runs on iPad, iPhone and iPod touch devices. The operating system
manages the device hardware and provides the technologies required to implement native apps.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


• The iOS Software Development Kit (SDK) contains the tools and interfaces needed to develop, install, run,
and test native apps that appear on an iOS device's Home screen.
• Fig. 7.7.1 shows iOS architecture.

• 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.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


Media Layer
• The role of the Media layer is to provide iOS with audio, video, animation and graphics capabilities.
• As with the other layers comprising the iOS stack, the media layer comprises a number of frameworks
which may be utilized when developing iPhone apps.
• The technologies in this layer make it easy for sound great.
a. Graphics technologies
b. Audio technologies
c. Video technologies
d. AirPlay.
• Media layer contains following frameworks:
1. Core video framework: This framework provides buffering support for the AMI Ista Core media
framework. Whilst this may be utilized by application developers it is typically not necessary to use this
framework.
2. Core text framework: The iOS core text framework is a C-based API designed to ease the handling of
advanced text layout and font rendering requirements.
3. Image I/O framework: The Image I/O framework, the purpose of which is to facilitate the importing and
exporting of image data and image metadata, was introduced in iOS 4. The framework supports a wide range
of image formats including PNG, JPEG, TIFF and GIF.
4. Assets library framework: The assets library provides a mechanism for locating and retrieving video and
photo files located on the iPhone device. In addition to accessing existing images and videos, this framework
also allows Simon new photos and videos to be saved to the standard device photo album.
5. Core graphics framework: The iOS core graphics framework provides a lightweight two dimensional
rendering engine. Features of this framework include PDF document creation and presentation, vector based
drawing, transparent layers, path based drawing, anti-aliased rendering, color manipulation and management,
image rendering and gradients.
6. Core image framework: A new framework introduced with iOS 5 providing a set of video and image
filtering and manipulation capabilities for application developers.
7. Quartz core framework: The purpose of the Quartz Core framework is to provide animation capabilities
on the iPhone. It provides the foundation for the majority of the visual effects and animation used by the
UIKit framework and provides an Objective-C based programming interface for creation of specialized
animation within iPhone apps.
8. OpenGL ES framework: For many years the industry standard for high performance 2D and 3D graphics
drawing has been OpenGL. OpenGL for Embedded Systems (ES) is a lightweight version of the full
OpenGL specification designed specifically for smaller devices such as the iPhone.
9. GLKit framework: The GLKit framework is an Objective-C based API designed to ease the task of
creating OpenGL ES based applications.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


10. NewsstandKit framework: The Newsstand application is a new feature of iOS 5 and is intended as a
central location for users to gain access to newspapers and magazines. The NewsstandKit framework allows
for the development of applications that utilize this new service.
11. iOS audio support: iOS is capable of supporting audio in AAC, Apple orolove Lossless (ALAC), A-law,
IMA/ADPCM, Linear PCM, u-law, DVI/Intel IMA ADPCM, Microsoft GSM 6.10 and AES3-2003 formats
through the support provided by the following frameworks.
12. AV foundation framework: An Objective-C based framework designed to allow the playback, recording
and management of audio content.
Core Services Layer
• The Core Services layer contains fundamental system services for apps.
• Key among these services are the core foundation and foundation frameworks, which define the basic types
that all apps use.
• This layer also contains individual technologies to support features such as location, iCloud, social media
and networking.
Features:
1. Peer-to-Peer services
2. iCloud storage
3. Automatic reference counting
4. Block objects
5. Grand central dispatch
6. In-App purchase
7. SQLite
8. XML support
9. File-sharing support, data protection.
It consists of the following frameworks:
•Address book framework: This provides programmatic access to the iPhone Address Book contact
database allowing applications to retrieve and modify contact entries.
• CFNetwork framework: The CFNetwork framework provides a C-based interface to the TCP/IP
networking protocol stack and low level access to BSD sockets. This enables application code to be written
that works with HTTP, FTP and domain name servers and to establish secure and encrypted connections
using Secure Sockets Layer (SSL) or Transport Layer Security (TLS).
• Core Data Framework: This framework is provided to ease the creation of data modeling and storage in
Model-View-Controller (MVC) based applications. Use of the Core Data framework significantly reduces
the amount of code that needs to be written to perform common tasks when working with structured data
within an application.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


• Core foundation framework: The core foundation framework is a C-based Framework which provides
basic functionality such as data types, string manipulation, raw block data management, URL manipulation,
threads and run loops, date and times, basic XML manipulation and port and socket anro communication.
• The core media framework is the lower level foundation upon which the AV foundation layer is built.
• Core telephony framework: The iOS core telephony framework is provided to allow applications to
interrogate the device for information about the current cell phone service provider and to receive
notification of telephony related events.
• EventKit framework: An API designed to provide applications with access to the calendar and alarms on
the device.
• Most applications will use iCloud document storage to share documents from a user's iCloud account. This
is the feature that users think of when they think of iCloud storage. A user cares about whether documents
are shared across devices and can see and manage those documents from a given device.
• Data protection allows applications that work with sensitive user data to take advantage of the built-in
encryption available on some devices.
• When your application designates a specific file as protected, the system stores that file on-disk in an
encrypted format. While the device is locked, the contents of the file are inaccessible to both your
application and to any potential intruders.
• However, when the device is unlocked by the user, a decryption key is created to allow your application to
access the file.
Core OS Layer
• The Core OS layer contains the low-level features that most other technologies are built upon.
• Even if you do not use these technologies directly in your apps, they are most likely being used by other
frameworks.
• And in situations where you need to explicitly deal with security or communicating with an external
hardware accessory, you do so using the frameworks in this layer.
• This layer provides a variety of services including low level networking, access to external accessories and
the usual fundamental operating system services such as memory management, file system handling and
threads.
• The Core OS layer occupies the bottom position of the iOS stack and, as such, sits directly on top of the
device hardware.
• The layer provides a variety of services including low level networking, access to external accessories and
the usual fundamental operating system services such as memory management, file system handling and
threads.
• Accelerate framework: Introduced in iOS 4.0, the Accelerate framework contains. interfaces for performing
DSP, linear algebra and image-processing calculations. The advantage of using this framework over writing
your own versions of these interfaces is that they are optimized for all of the hardware configurations present
• in iOS, based devices. Therefore, you can write your code once and be assured that it runs efficiently on all
devices.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


• External accessory framework: It provides the ability to interrogate and communicate with external
accessories connected physically to the iPhone via the 30-pin dock connector or wirelessly via Bluetooth.
• Security framework: The iOS Security framework provides all the security interfaces you would expect to
find on a device that can connect to external networks including certificates, public and private keys, trust
policies, key chains, encryption, digests and Hash-based Message Authentication Code (HMAC).
• The core bluetooth framework allows developers to interact specifically with 80 Bluetooth Low-Energy
("LE") accessories. The Objective-C interfaces of this framework allow you to scan for LE accessories,
connect and disconnect to ones you find, read and write attributes within a service, register for service and
attribute change notifications and much more.
• System: The system level encompasses the kernel environment, drivers and low level UNIX interfaces of
the operating system. The kernel itself is based on Mach and is responsible for every aspect of the operating
system.
• It manages the virtual memory system, threads, file system, network and interprocess communication. The
drivers at this layer also provide the interface between the available hardware and system frameworks.
• For security purposes, access to the kernel and drivers is restricted to a limited set of system frameworks
and applications.
• iOS provides a set of interfaces for accessing many low-level features of the operating system. Your
application accesses these features through the LibSystem library.
5.8 Android File Management
• Android uses a file system that's similar to disk-based file systems on other platforms. A file object is suited
to reading or writing large amounts of data in start-to-finish order without skipping around.
• All Android devices have two file storage areas: "Internal" and "external" storage.
• Android device may use an updated Linux file system, such as ext4 or a proprietary file system by a
manufacturer, depending on who made the device and what has been done to it by the user.
• File system is the collection place on disk device for files. Visualize the file system as consisting of a single
node at the highest level (ROOT) and all other nodes descending from the root node in a tree-like fashion.
• Samsung Galaxy S phones use the Samsung RFS proprietary file system while the Samsung Nexus S with
Android 2.3 uses the Linux Ext4 file system.
• < /mnt>: This directory is used for mount points. The different physical storage devices (like the hard disk
drives, floppies, CD-ROM's) must be attached to some au directory in the file system tree before they can be
accessed. This attaching is no called mounting and the directory where the device is attached is called the
mount bne point.
• SDCard: The mounted SDCard is a storage device mounted to the file system in the typical Linux fashion.
On the file system root the /sdcard is a symbolic link to /mnt/sdcard. /mnt/sdcard is where the SD card is
actually mounted, but the same files can also be accessed in /sdcard.
• Fig. 7.8.1 shows typical directory structure of android file system.

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)

• 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

SubCode:CS3451 Subject Name: Operating System


Department of Information Technology

(An Autonomous Institution)


• SQlite is an open source embedded database. The resulting design goals of SQLite were to allow the
program to be operated without a database installation or administration.
• It most widely deployed SQL database engine in the world. SQLite is based on the Structured Query
Language (SQL). Android contains the SQLite database management classes that an application would use
to manage its own private database.
• SQLite is open source SQL database that stores data to a text file on a device. Android comes in with built
in SQLite database implementation. SQLite supports all the relational database features.
• It is designed to provide a streamlined SQL-based database management system suitable for embedded
systems and other limited memory systems. The full SQLite mid library can be implemented in under 400
KB.
• In contrast to other database management systems, SQLite is not a separate process that is accessed from
the client application. The library is linked in and thus becomes an integral part of the application program.
Unique Features
1. No configuration is required.
2. No server process to administer or user accounts to manage.
3. Easy to backup and transmit database.
4. Dynamic typing for column values, variable lengths for column records.
5. Query can reference multiple database files.
6. A few non-standard SQL extensions.
• SQLiteDatabase allows methods to open the database connection, perform queries and query updates and
close the database. You can define keys and values for queries via the ContentValues object. This is
necessary for Insert and Update calls. Delete only requires the Row Number.
• android.database.sqlite classes are as follows:
1. SQLiteCloseable - An object created from a SQLiteDatabase that can be closed.
2. SQLiteCursor - A cursor implementation that exposes results from a query on a SQLiteDatabase.
3. SQLiteDatabase - Exposes methods to manage a SQLite database.
4. SQLiteOpenHelper - A helper class to manage database creation and version management.
5. SQLiteProgram- A base class for compiled SQLite programs.
6. SQLiteQuery - A SQLite program that represents a query that reads the as resulting rows into a
CursorWindow.
7. SQLiteQueryBuilder- A convenience class that helps build SQL queries to be sent to SQLiteDatabase
objects.
8. SQLiteStatement - A pre-compiled statement against a SQLiteDatabase that can be reused.

SubCode:CS3451 Subject Name: Operating System

You might also like