0% found this document useful (0 votes)
4 views15 pages

CHCH 2

ch2 operating system
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views15 pages

CHCH 2

ch2 operating system
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Chapter 2:

Operating-System
Services Outline
Operating System Services
User and Operating System-Interface
System Calls
System Services
Linkers and Loaders
Why Applications are Operating System Specific
Design and Implementation
Operating System Structure
Building and Booting an Operating System
Operating System Debugging
Objectives
Identify services provided by an operating system
Illustrate how system calls are used to provide operating system services
Compare and contrast monolithic, layered, microkernel, modular, and hybrid strategies for
designing operating systems
Illustrate the process for booting an operating system
Apply tools for monitoring operating system performance
Design and implement kernel modules for interacting with a Linux kernel
Operating System Services

The OS helps run programs and supports users in various ways, like giving them
interfaces to interact with, handling program execution and errors, managing files and
communication, and making sure the system runs smoothly by sharing resources and
keeping everything safe and secure./
The OS helps run programs and supports users in various ways, like giving them
interfaces to interact with, handling program execution and errors, managing files and
communication, and making sure the system runs smoothly by sharing resources and
keeping everything safe and secure.

A View of Operating System Services


Operating systems help users run programs, manage files, and share resources safely.

Command Line interpreter

The command line takes direct commands, fetching and executing them, often with different versions called shells, allowing for easy feature
additions without changing the shell itself. /
Sure, the command line takes your commands and does what you ask, and sometimes different versions called shells help with that, making
it easy to add new things without changing the main part.

Bourne Shell Command Interpreter


The Bourne Shell takes your typed commands and tells the computer what to do based on those instructions.
User Operating System Interface – GUI

The GUI, or Graphical User Interface, is a user-friendly way to interact with your computer using pictures, buttons, and windows instead of
just text. You can click on icons to open programs, access files, and perform various actions /The GUI lets you use your computer through
pictures and buttons. You click icons to open stuff or do things on your screen.

Touchscreen Interfaces
Touchscreen stuff lets you do things by tapping and swiping. You use your fingers for actions, like typing or selecting, and sometimes even
talk to it for commands. /Touchscreens let you do stuff by tapping and swiping with your fingers. You can choose things and type using a
virtual keyboard, and some even listen to your voice commands.

The Mac OS X GUI

The Mac OS X GUI is an interface with icons and visual elements that you can control using a mouse or trackpad to perform tasks on a Mac
computer.

System Calls
programming interface to the services provided by the OS Typically written in a high-level language (C or C++) Mostly accessed by
programs via a high-level Application Programming Interface (API) rather than direct system call use 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), and Java API for the
/ System calls are like a phone line for programs to talk to the operating
Java virtual machine (JVM)

system, letting them access its services using different sets of rules depending on the system
they're running on./System calls are a way for programs to ask the operating system for help or
services, using different sets of rules based on the system they're running on.

Example of System Calls

When you open a file, write to it, or close it, those actions are examples of system calls in action.
System call sequence to copy the contents of one file to another file

Example of Standard API


Standard APIs like Win32 or POSIX allow programs to use pre-built functions for tasks like file manipulation or memory management without
knowing their underlying implementations

system Call Implementation


System calls are like numbered requests in a list. When a program wants something from the operating system, it picks the matching number
from this list. The operating system then deals with the request and gives back the result. The program using the system call doesn’t need to
know how it works inside the system, just how to ask and what to expect in return. All the complex stuff about how it's done is hidden away,
managed by a bunch of tools provided by the system. /System calls are like asking for things by number. When a program needs something
from the system, it uses a number to ask, and the system takes care of the request and gives back what's needed. The program doesn't
need to know all the details; it just asks and gets what it needs. All the complicated stuff is handled behind the scenes by tools from the
system.
API – System Call – OS Relationship

APIs act as an intermediary between applications and the operating system, using system calls to access OS functionality. /APIs are like
messengers between programs and the operating system, using system calls to get things done.
System Call Parameter Passing
System calls often need more than just the call's name, so they use different ways to send information to the OS. Sometimes it's put in
registers, stored in memory blocks, or pushed onto a stack. These methods help handle different types and amounts of information. /System
calls need more than just their name to work, so they use different ways to send information to the OS. They might use registers, memory
blocks, or a stack to handle the details.

Parameter Passing via Table


When using the table method, parameters for system calls are stored together in a block of memory, and the address of that block is passed
to the OS. /
In the table method, all the system call parameters gather together in a block of memory, and the OS gets that block's address to access
them.

Types of System Calls

Types of System Calls


Process Control
• Start, stop, manage processes
• Memory operations and debugging
2. File Management

• Create, delete, read, write files


• File attributes management
3. Device Management
• Request, release, and use devices
• Device attribute management
4. Information Maintenance

• Manage system time, data, and attributes


5. Communication

• Establish, delete connections


• Send and receive messages
6. Shared Memory

• Access and use shared memory regions


7. Protection

• Control access to resources


• Set permissions and manage user access

Examples of Windows and Unix System Calls


Windows System Call: In Windows, CreateProcess is used to create a new process.
Unix System Call: In Unix, fork is used to create a new process, followed by exec to execute a new
program in that process.
Standard C Library Example
In C, printf from the standard C library is used to display output on the screen.

C program invoking printf() library call, which calls write() system call

Example: Arduino

At system startup running a


program

Arduino boards function without an operating system, using a single-tasking approach where programs, called sketches, are loaded through
USB into flash memory and run in a single memory space. /Arduino works without an operating system. Programs, called sketches, are
loaded from a computer using USB into the device's memory and run without a separate operating system.

Example: FreeBSD
In FreeBSD, like other Unix systems, when a user logs in, they choose a shell. The shell uses system calls like fork() to create new
processes and exec() to load programs. When a process ends, it can exit smoothly (code = 0) or with an error (code > 0). /
In FreeBSD, when a user logs in, their chosen shell creates new tasks and runs programs using simple commands. When a task finishes, it
either ends without trouble or might have an error.

System Services
System services are like helpful tools for running programs on your computer. They do lots of things, like managing files, giving info about
your computer, helping with programming, letting programs run, making connections between different parts of the computer, and running in
the background. These programs make it easier to use the computer and help other programs run smoothly. /System services are programs
that help with developing and running other programs. They handle tasks like managing files, providing status info, aiding in programming,
handling communication between users and systems, and running in the background. These programs are like tools for users and aren't
always seen as part of the operating system itself.
Linkers and Loaders

Linkers put together different parts of a program to make it work as one, combining them into a file that can be run. Loaders then bring this
file into memory so it can be used. They also manage the final addresses where each part of the program will be placed in the computer's
memory. When programs need extra help, they can use shared libraries that are loaded only when they're needed. This way, programs can
share these libraries, saving memory space. /Linkers merge program parts together, making one file. Loaders bring this file into memory so it
can run. They set the right spots for each part in memory. Programs can share libraries, saving space.
The Role of the Linker and Loader

The linker combines program parts into a single file, while the loader brings this file into memory to run it properly.
Why Applications are Operating System Specific
Applications are often tied to specific operating systems because each system has its own unique system calls, file formats, and interfaces
that applications need to work properly. However, some apps can be designed to work across multiple systems by using interpreted
languages, virtual machines, or by following standard language practices. /
Apps usually work only on specific operating systems because each one has its own special rules and tools that apps need to run correctly.
Some apps can work on different systems by using certain programming languages or standards.

Design and Implementation

Designing an OS isn't easy to solve, but some ways have worked well. OS designs change based on the computer and system they're for. It
begins with goals and plans affected by hardware and what the system needs. These goals include making it easy and safe for users and
simple to create and maintain for the system. Building an OS is a creative task in software engineering. /
Designing an operating system isn't an easy problem to solve, but some methods have worked well. It all starts with setting goals and plans,
influenced by the computer and what the system needs. Users want it to be easy and safe, while the system needs it to be simple to build
and manage. Creating an OS is a creative job in software design.

Policy and Mechanism


Policy is what needs to happen, like setting an interrupt every 100 seconds. Mechanism is how to make it happen, such as using a timer.
Keeping these separate is crucial because it allows easy changes. For instance, changing 100 seconds to 200 seconds is simpler when
policy and mechanism are separate. /Policy is the "what" - like setting an interrupt for 100 seconds. Mechanism is the "how" - using
something like a timer. Keeping them separate is smart because it makes changes easier, like adjusting the time from 100 to 200 seconds

Implementation
In the past, operating systems were in assembly language, then came languages like Algol and PL/1. Now, they're mostly in C or C++,
sometimes mixing with scripting languages. Assembly handles the lowest bits, C does most, and other languages make things easier to
move but a bit slower. Emulation helps OSes run on different hardware. /
Old operating systems used assembly language, then came Algol and PL/1. Now, they're mostly in C or C++, mixed with other languages
like Python. Assembly works at the lowest level, C does most of the work, and other languages make it easier to move things around but can
be slower. Emulation helps OSes work on different hardware

Operating System Structure

Operating systems are big programs, and they can be organized in different ways. Some are simple like MS-DOS, others more complex like
UNIX. There are layered ones, which use abstraction, and microkernels like Mach /Operating systems are like big programs. They come in
different types: simple ones like MS-DOS, more complex ones like UNIX, those with layers, and microkernels like Mach.

Monolithic Structure – Original UNIX


UNIX, the original operating system, had a basic structure. It had two main parts: system programs and the kernel. The kernel did all the
essential work, like managing files, memory, and the CPU. It handled a lot of tasks all by itself /
UNIX, the first system, had two main parts: programs and the kernel. The kernel handled essential tasks like managing files and memory,
doing a lot of work on its own.

traditional UNIX System Structure


The classic UNIX system had a basic structure with two main parts: the kernel handling core operations and the system programs interacting
with users.

Beyond simple but not fully layered

Linux System Structure


Monolithic plus modular design

Linux follows a modular structure, with the kernel managing core functions and system utilities handling user interactions.
Layered Approach

The operating system is split into layers, from hardware at the bottom to the user interface at the top. Each layer uses only the functions from
the layers below it. /The operating system is like a cake with layers, starting from hardware at the bottom and ending with what you see on
the screen at the top. Each layer only uses what's underneath it.

Microkernels
Microkernels are like a trimmed-down version of the usual operating system. They keep less stuff in the central part, making it
easier to add new things and move it to different kinds of computers. They talk to each other using messages. It's safer and more
secure, but talking between parts can make it slower. /
Microkernels are like a streamlined operating system, with less stuff in the main part. This makes it easier to add new features and use it on
different types of computers. They communicate using messages, which is safer, but can make things a bit slower.

Microkernel System Structure


A microkernel system has a small and basic core that manages essential tasks, with other functions running as separate modules
outside the core. /Microkernel systems put only the essential functions in the core, making it easier to expand and adapt, but sometimes at
the cost of slower communication.

Modules
Modules in modern operating systems act as separate, loadable parts of the core,
communicating through known interfaces, like layers but more adaptable and flexible. Linux
and Solaris use this approach./ In some operating systems like Linux and Solaris, modules work as separate parts that can
be added when needed, communicating through known interfaces.

Hybrid Systems
Modern operating systems like Linux, Windows, and Mac OS X use a mix of different methods to balance performance, security,
and usability. For example, Windows mainly uses a monolithic structure with a touch of microkernel for various subsystems, while
Mac OS X blends a microkernel called Mach with BSD Unix and other elements for its core. Linux and Solaris also blend monolithic
/ Modern systems like Linux,
and modular approaches by loading functionality as needed into their kernel.

Windows, and Mac OS X mix different methods for better performance, safety, and ease of
use. For instance, Windows mainly uses one style but adds a little bit of another for different
parts. Mac OS X combines a microkernel with other elements, and Linux and Solaris load
features when needed into their core.
macOS and iOS Structure

MacOS and iOS have similar core structures; both are based on Unix-like kernels with added layers for user interfaces and
frameworks designed specifically for their respective platforms. /Both macOS and iOS rely on a core system inspired by Unix, with
unique layers for their interfaces and specific features for each platform.

Darwin
Darwin serves as the foundational operating system for macOS and iOS, built on a Unix-like core.

IOS

iOS is Apple's mobile operating system found on devices like the iPhone and iPad, built from Mac OS X with added features. It
doesn't directly run Mac apps, operates on ARM architecture, and uses tools like Cocoa Touch Objective-C API for app
development. Core services include media, cloud computing, and databases, all supported by the Mac OS X kernel. /
iOS is Apple's mobile operating system for iPhones and iPads. It's based on Mac OS X but has its own features. It can't run Mac apps
directly, works on a different chip, and uses tools like Cocoa Touch Objective-C API for making apps. It also has core services like media and
cloud features, all run by the Mac OS X kernel.
Android
Android is made by a group called the Open Handset Alliance, mainly led by Google. It's open source and works similarly to iOS. It
uses a modified Linux core and manages processes, memory, and devices, with added power control. For apps, developers use
Java and the Android API. These apps run on the Dalvik virtual machine after being translated from Java code. Android also has
libraries for things like web browsing, databases, and multimedia. /Android is a system by a group led by Google, called the Open
Handset Alliance. It's open source and handles tasks like managing processes and devices. Developers use Java to make apps that run on
its virtual machine.

Android Architecture
Android's architecture, based on a modified Linux kernel, oversees process management, memory handling, and device drivers,
supporting Java-based apps via its Dalvik virtual machine.

Building and Booting an Operating System


To make an operating system from scratch:
1. Write the OS code.
2. Set it up for the specific system.
3. Compile the OS.
4. Install it.
5. Start the computer with the new OS.

/
To create an operating system:
1. Write the code.
2. Configure it for the computer.
3. Compile and install.
4. Start the computer with the new system.

Building and Booting Linux


1Get Linux code from http://www.kernel.org .
1. Setup kernel with “make menuconfig”.
2. Make the kernel with “make”.
3. This makes vmlinuz, the kernel image.
4. Create modules with “make modules”.
5. Combine modules into vmlinuz using “make modules_install”.
6. Install new kernel using “make install”.

System Boot
1 When you power on your computer, it looks for the operating system.

1. The bootstrap loader, stored in ROM, finds the kernel, loads it into memory, and starts it.
2. On modern systems, Unified Extensible Firmware Interface (UEFI) replaces BIOS.
3. GRUB, a common loader, helps pick the kernel and start the system.
4. The kernel loads, and your system is up and running!/

/When you turn on your computer, a little program finds and starts the main operating system. It's like
a key that unlocks the computer and gets everything running smoothly.

Operating-System Debugging

Operating-system debugging is like finding and fixing mistakes in computer programs. It also helps improve how fast the system
works. The OS keeps logs of problems, like when apps stop working. It can also store details about why the whole system crashed.
To make things faster, the system can be fine-tuned, using records of what the computer does, kind of like checking its pulse. But
remember, fixing mistakes is even trickier than writing the code in the first place! /Debugging an operating system is like finding and
fixing mistakes in a computer. It keeps logs of problems, like when apps stop working, and notes why the whole system crashed. To make
things faster, it fine-tunes the system, using records of what the computer does. But remember, fixing mistakes is even trickier than writing
the code in the first place!

performance Tuning
Performance tuning is about making your computer faster by getting rid of things that slow it down. The operating system has tools like "top"
on some systems or Task Manager on Windows that show how the computer is doing and where it might be getting stuck. /
Performance tuning helps speed up your computer by finding and fixing things that slow it down. Operating systems have tools like "top" or
Task Manager to show what might be causing these slowdowns.
Tracing

Tracing is like taking notes on what your computer is doing for specific tasks, like when a program uses system features. Tools
such as "strace," "gdb," "perf," and "tcpdump" help track these actions. /It's like keeping track of what your computer's doing when
certain things happen, using tools like "strace" or "gdb."

strace –
trace system calls invoked by a process
gdb – source-level debugger
perf – collection of Linux performance tools
tcpdump – collects network packets

BCC
think of BCC like a special set of tools that helps understand how your computer's inside parts (the kernel) talk to the things you
do on the screen (the user-level stuff). It's like having a special translator to understand and track how they communicate /
BCC is a special set of tools that helps understand how the deep-down computer stuff talks to what you see on the screen. It's like a
translator to track how they communicate and work together

Linux bcc/BPF Tracing Tools


These tools help understand and track how different parts of Linux talk to each other, showing what's happening behind the
scenes.

You might also like