Operating Systems 2019 20 Week 1 OS Case














































- Slides: 46

Operating Systems 2019 -20 Week 1: OS Case Studies Manal Helal Joey Lam COM 1032

From Introduction to Android™ Application Development, Android Essentials, Fiftth Edition, by Joseph Annuzzi, Jr. , Lauren Darcey, and Shane Conder (ISBN-13: 978 -0 -134 -38945 -5) Copyright © 2016 Pearson

From Introduction to Android™ Application Development, Android Essentials, Fiftth Edition, by Joseph Annuzzi, Jr. , Lauren Darcey, and Shane Conder (ISBN-13: 978 -0 -134 -38945 -5) Copyright © 2016 Pearson

Operating System Market Share http: //blog. jackstechcorner. com/does-operating-systems-matter/

Operating System Structure » General-purpose OS is very large program » Various ways to structure ones • • Simple structure – MS-DOS More complex -- UNIX Layered – an abstrcation Microkernel -Mach

Simple Structure -- MS-DOS » MS-DOS – written to provide the most functionality in the least space • Not divided into modules • Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated

Non Simple Structure -- UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts • Systems programs • The kernel • Consists of everything below the system-call interface and above the physical hardware • Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level

Traditional UNIX System Structure Beyond simple but not fully layered

Layered Approach » The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. » With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers

Microkernel System Structure » Moves as much from the kernel into user space » Mach example of microkernel • Mac OS X kernel (Darwin) partly based on Mach » Communication takes place between user modules using message passing » Benefits: • • Easier to extend a microkernel Easier to port the operating system to new architectures More reliable (less code is running in kernel mode) More secure » Detriments: • Performance overhead of user space to kernel space communication

Microkernel System Structure

Modules » Many modern operating systems implement loadable kernel modules • • Uses object-oriented approach Each core component is separate Each talks to the others over known interfaces Each is loadable as needed within the kernel » Overall, similar to layers but with more flexible • Linux, Solaris, etc

Hybrid Systems » Most modern operating systems are actually not one pure model • Hybrid combines multiple approaches to address performance, security, usability needs • Linux and Solaris kernels in kernel address space, so monolithic, plus modular for dynamic loading of functionality • Windows mostly monolithic, plus microkernel for different subsystem personalities » Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa programming environment • Below is kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit and dynamically loadable modules (called kernel extensions)

Mac OS X Structure

i. OS » Apple mobile OS for i. Phone, i. Pad • Structured on Mac OS X, added functionality • Does not run OS X applications natively • Also runs on different CPU architecture (ARM vs. Intel) • • Cocoa Touch Objective-C API for developing apps Media services layer for graphics, audio, video Core services provides cloud computing, databases Core operating system, based on Mac OS X kernel

Android » Developed by Open Handset Alliance (mostly Google) • Open Source » Similar stack to IOS » Based on Linux kernel but modified • Provides process, memory, device-driver management • Adds power management » Runtime environment includes core set of libraries and Dalvik virtual machine • Apps developed in Java plus Android API • Java class files compiled to Java bytecode then translated to executable than runs in Dalvik VM » Libraries include frameworks for web browser (webkit), database (SQLite), multimedia, smaller libc

Android Architecture

System Boot » When power initialized on system, execution starts at a fixed memory location • Firmware ROM used to hold initial boot code » Operating system must be made available to hardware so hardware can start it • Small piece of code – bootstrap loader, stored in ROM or EEPROM locates the kernel, loads it into memory, and starts it • Sometimes two-step process where boot block at fixed location loaded by ROM code, which loads bootstrap loader from disk » Common bootstrap loader, GRUB, allows selection of kernel from multiple disks, versions, kernel options » Kernel loads and system is then running

MS Windows Executive © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Windows Objects » Windows draws heavily on the concepts of object-oriented design » Key object-oriented concepts used by Windows are: Inheritance Encapsulation Object class and instance © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved. Polymorphism

Windows objects There are two categories of objects used by Windows for synchronizing the use of the processor: • Dispatcher objects: The subset of Executive objects which threads can wait on to control the dispatching and synchronization of thread-based system operations. • Control objects: Used by the Kernel component to manage the operation of the processor in areas not managed by normal thread scheduling. Table 2. 5 lists the Kernel control objects. © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved. Table 2. 5 Windows Kernel Control Objects

Traditional UNIX Systems » Developed at Bell Labs and became operational on a PDP-7 in 1970 » The first notable milestone was porting the UNIX system from the PDP-7 to the PDP-11 • First showed that UNIX would be an OS for all computers » Next milestone was rewriting UNIX in the programming language C • Demonstrated the advantages of using a high-level language for system code • Was described in a technical journal for the first time in 1974 • First widely available version outside Bell Labs was Version 6 in 1976 • Version 7, released in 1978, is the ancestor of most modern UNIX systems • Most important of the non-AT&T systems was UNIX BSD (Berkeley Software Distribution), running first on PDP and then on VAX computers © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

© 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

© 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

From Introduction to Android™ Application Development, Android Essentials, Fiftth Edition, by Joseph Annuzzi, Jr. , Lauren Darcey, and Shane Conder (ISBN-13: 978 -0 -134 -38945 -5) Copyright © 2016 Pearson

LINUX Overview » Started out as a UNIX variant for the IBM PC » Linus Torvalds, a Finnish student of computer science, wrote the initial version » Linux was first posted on the Internet in 1991 » Today it is a full-featured UNIX system that runs on virtually all platforms » Is free and the source code is available » Key to the success of Linux has been the availability of free software packages under the auspices of the Free Software Foundation (FSF) » Highly modular and easily configured © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Modular Structure » Relatively independent blocks » A module is an object file whose code can be linked to and unlinked from the kernel at runtime » A module is executed in kernel mode on behalf of the current process » Have two important characteristics: • Dynamic linking • Stackable modules » Loadable Modules n Linux development is global and done by a loosely associated group of independent developers n Although Linux does not use a microkernel approach, it achieves many of the potential advantages of the approach by means of its particular modular architecture n Linux is structured as a collection of modules, a number of which can be automatically loaded and unloaded on demand © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

© 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

© 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Linux Signals Table 2. 6 Some Linux Signals © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Table 2. 7 Some Linux System Calls (page 1 of 2) © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Table 2. 7 Some Linux System Calls (page 2 of 2) © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Android Operating System » A Linux-based system originally designed for mobile phones » The most popular mobile OS » Development was done by Android Inc. , which was bought by Google in 2005 » 1 st commercial version (Android 1. 0) was released in 2008 » Most recent version is Android 9. 0 (Pie) » Android has an active community of developers and enthusiasts who use the Android Open Source Project (AOSP) source code to develop and distribute their own modified versions of the operating system » The open-source nature of Android has been the key to its success https: //source. android. com/setup/start/build-numbers. html © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

© 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Application Framework » Provides high-level building blocks accessible through standardized API’s that programmers use to create new apps • Architecture is designed to simplify the reuse of components » Key components: Activity Manager Window Manager Manages lifecycle of applications Java abstraction of the underlying Surface Manager Responsible for starting, stopping, and resuming the various applications © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved. Allows applications to declare their client area and use features like the status bar Package Manager Telephony Manager Installs and removes applications Allows interaction with phone, SMS, and MMS services

Application Framework (cont. ) Content Providers These functions encapsulate application data that need to be shared between applications such as contacts Resource Manager Manages application resources, such as localized strings and bitmaps © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved. View System Location Manager Notification Manager XMPP Provides the user interface (UI) primitives as well as UI Events Allows developers to tap into locationbased services, whether by GPS, cell tower IDs, or local Wi-Fi databases Manages events, such as arriving messages and appointments Provides standardized messaging functions between applications

System Libraries » Collection of useful system functions written in C or C++ and used by various components of the Android system » Called from the application framework and applications through a Java interface » Exposed to developers through the Android application framework » Some of the key system libraries include: • • • Surface Manager Open. GL Media Framework SQL Database Browser Engine Bionic Lib. C © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Android Runtime n Most Android software is mapped into a bytecode format which is then transformed into native instructions on the device itself n Earlier releases of Android used a scheme known as Dalvik, however Dalvik has a number of limitations in terms of scaling up to larger memories and multicore architectures n More recent releases of Android rely on a scheme known as Android runtime (ART) n ART is fully compatible with Dalvik’s existing bytecode format so application developers do not need to change their coding to be executable under ART n Each Android application runs in its own process, with its own instance of the Dalvik VM © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

© 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Advantages and Disadvantages of Using ART » Advantages » Disadvantages » Reduces startup time of applications as native code is directly executed » Because the conversion from bytecode to native code is done at install time, application installation takes more time » On the first fresh boot or first boot after factory reset, all applications installed on a device are compiled to native code using dex 2 opt, therefore the first boot can take significantly longer to reach Home Screen compared to Dalvik » The native code thus generated is stored on internal storage that requires a significant amount of additional internal storage space » Improves battery life because processor usage for JIT is avoided » Lesser RAM footprint is required for the application to run as there is no storage required for JIT cache » There a number of Garbage Collection optimizations and debug enhancements that went into ART © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

© 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Activities An activity is a single visual user interface component, including things such as menu selections, icons, and checkboxes Every screen in an application is an extension of the Activity class Activities use Views to form graphical user interfaces that display information and respond to user actions © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved.

Power Management » Alarms » Implemented in the Linux kernel and is visible to the app developer through the Alarm. Manager in the Run. Time core libraries » Is implemented in the kernel so that an alarm can trigger even if the system is in sleep mode • This allows the system to go into sleep mode, saving power, even though there is a process that requires a wake up » Wakelocks » Prevents an Android system from entering into sleep mode » These locks are requested through the API whenever an application requires one of the managed peripherals to remain powered on » An application can hold one of the following wakelocks: • • © 2017 Pearson Education, Inc. , Hoboken, NJ. All rights reserved. Full_Wake_Lock Partial_Wake_Lock Screen_Dim_Wake_Lock Screen_Bright_Wake_Lock

From Introduction to Android™ Application Development, Android Essentials, Fiftth Edition, by Joseph Annuzzi, Jr. , Lauren Darcey, and Shane Conder (ISBN-13: 978 -0 -134 -38945 -5) Copyright © 2016 Pearson

General Booting Sequence BIOS (basic input/output system) POST (Power-On Self Test) BIOS Boot Handoff The Boot Device The Master Boot Record (MBR) https: //neosmart. net/wiki/mbr-boot-process/ Android Booting Sequence

46