CS代考程序代写 assembler gui Java distributed system file system FTP compiler interpreter flex CSI3131 Module 1

CSI3131 Module 1

Overview
Introduction / of OS
1
▪ Do a quick overview of the organization of
▪ Introduce the operating system to understand its role and main functions
Reading: Chapter
and
2
(Silberchatz)
Goal:

computers
input / output, architecture and general operations.
processor (CPU), memory, and
1

Organization
Computer system
Operating system
2

Memory
Device Controllers
CPU
Hardware
Organization
Computer system
Operating system
Bus
3

Main hardware
▪ Processor (CPU)
▪ Main memory (real memory, RAM)
▪ Contains code and data
▪ I / O Modules (I / O Controllers, I / O Processors …)
▪ hardware (with registers: I / O ports) for data transport between CPUs and peripherals such as:
• secondary memory (e.g. hard disks)
• keyboard, screen …
• Communication equipment
▪ Interconnection (ie: Bus)
▪ for communication between processor (s), memory and I / O modules
4

Memory
Device Controllers
CPU
Hardware
Memory Structure
Organization
Computer system
Operating system
Bus
Secondary Memory Main Memory
5

Memory structure
▪ Main memory
▪ Accessible directly by the CPU
▪ A program must be in main memory to be executed by the CPU
▪ Main memory is not large enough to hold all programs and data
▪ The main memory is volatile – its content changes on loss of power or on restart.
▪ Secondary memory
▪ Contains large amounts of data / files, permanently.
▪ In general, a hierarchy exists for memory devices which varies according to speed, cost, size and volatility.
6

Hierarchy of memory devices
7

Hierarchical organization of memory
8

Memory
Device Controllers
Bus CPU
I/O
Structure
By interruption
DMA
Hardware
Memory Structure
Organization
Computer system
Operating system
Direct I/O
Secondary
Memory Main
Memory
9

Structure of the I / O controller
▪ Bus data are buffered in the “data register” (I / O ports)
▪ The “Status / Control” register contains:
▪ information on the status of the I/O operation ▪ the control information coming from the CPU
▪ The “I/O logic” circuit interacts with the CPU via the bus. ▪ Contains logic specific to the interface of each device
10

Communication techniques for I/O
▪ 3 techniques are possible: ▪ Scheduled I/O
• Does not use interrupts. CPU must wait after each I/O operation
▪ I/O triggered by interrupts
• The CPU can execute code during the I/O operation: it is interrupted when the operation is complete.
▪ Direct memory access (DMA)
• A block of data is transferred directly to / from memory without going through the CPU
11

I/ O
Interrupt
12

Modern computer operation
13

Memory
Multi processor
Clusters
Device Controllers
Bus
CPU
By
Direct interruption I/O
Secondary DMA Memory
Main Memory
One * processor
Hardware
I/O
Structure Architecture Memory
Structure
Organization
Computer system
Operating system
14

Computer systems architecture
▪ Systems with a single processor
▪ From PDA to central computer
▪ Almost all have specialized processors for graphics, I/O
• This is not considered to be multi-processor ▪ Multiprocessor systems
▪ Increased processing throughput ▪ Economies of scale
▪ Increased reliability
▪ Asymmetric multiprocessing
• Each processor is given a specific task
▪ Symmetric multiprocessing (most common) • All processors perform all OS tasks
▪ Clusters, distributed systems 15

Memory
Multi processor
Clusters
Device Controllers
Bus CPU
Structure Architecture Memory
interrupt Secondary DMA
Memory Main
One * processor
Hardware
I/O
Direct I/O
Structure
Organization
Computer System
Operating System
Memory
Services What is it?
User View
User Interfac GUI or CLI
16

Abstract view of the components of a computer system
17

Outlook for the
▪ This is my system, only I use it
▪ ie PC of which a user monopolizes
▪ OS maximizes user work (or play)
▪ OS designed for ease of use, not resource use. ▪ Portable systems – low hardware demand
▪ This is the big dedicated computer, I’m lucky to have CPU time
▪ ie the central computer or the minicomputer
▪ The OS is designed to maximize the use of resources (CPU, memory, I / O)
▪ Computer sharing
▪ ie workstations connected to a network of servers
▪ Dedicated and shared resources
▪ OS balances individual needs with resource utilization needs
▪ What? There is a computer inside.
▪ Embedded systems designed to run with minimal intervention
computer user
18

do operating
systems
do?
What
▪ Write a sentence or two that summarizes the role of the OS.
▪ OS is the program most involved with hardware • Material abstraction
▪ The OS allocates resources
• Manage all resources
• Deal with conflicting demands for efficient and fair use of resources
▪ OS is a control program
• Controls the execution of programs (ie processes) to avoid errors and misuse of the computer.
19

The definition of the operating system
▪ So what is the operating system?
▪ No universal definition accepted
▪ “Everything the supplier delivers when ordering an OS” is a first approximation
▪ But this varies a lot.
▪ “The program that runs all the time” is the one
used in this course
▪ This is the (Kernel)
▪ Any other program is a system program (delivered
with the OS) or an application program.
▪ What does “run all the time” mean? When I play Tetris, Tetris is executed by CPU – right?
20

System programs
▪ Are they part of the operating system
▪ Anything not in the kernel, but shipped with
the OS
▪ All depends on the OS and the supplier
▪ Can provide multiple system services, ie UNIX commands (CLI) are system programs for performing system tasks.
▪ Much of the user’s perspective on OS is defined by system programs, not directly by system calls to the kernel.
21

Systems program
▪ System programs (also called utility programs) provide an environment for program development and execution. Services:
▪ File management – ie copy, rm, ls, mkdir
▪ Status information – ie ps, who, regedit
▪ Editing files – editors
▪ Programming language service – ie cc, javac
▪ Loading and running programs – loaders, debuggers
▪ Communications – ssh, ftp
▪ Application programs – browsers, electronic pages, games
22

Services offered to user programs
▪ Input / Output operations
▪ Hardware access is through the kernel for the running
program
▪ Communications
▪ Communication between programs of the same
computer or with those of other computers
▪ Can be done with shared memory or messages
▪ Dealing with errors
▪ Detection
• Hardware errors (internal or external): memory, failure of an I / O device
• Software errors: overflows, prohibition of access to a memory slot
• Inability for OS to satisfy request
▪ Reaction: just report the error to the application, try the operation again, suspend the application
23

Services to ensure efficiency and proper functioning
▪ Resource allocation and management
▪ Required to serve multiple users and multiple
programs
▪ Some resources have their specific management code:
• CPU, main memory, file system
▪ Others are managed via a general code – I / O
▪ Accounting
▪ Statistics on the use of resources by users
▪ Protection and security
▪ Prevent intruders (unauthorized users) from accessing
the system
▪ Prevent users from accessing resources that are not intended for them
24

User interface
Command Line Interface (CLI) allows command entry directly from the keyboard
▪ The command interpreter is a program that reads commands typed by the user
• Often referred to as the “shell” (UNIX terminology) ▪ The execution of a command is done one of two
ways
• The interpreter executes the command
• Programming instructions allow the interpreter to execute
“shell” programs
• The command is used to start a separate program (eg a system program)

CLI
25


GUI
User interface
▪ User-friendly interface that represents a desktop surface ▪ With mouse, keyboard, and monitor
▪ Icons represent files, programs, actions, etc.
▪ Invented at Xerox PARC
▪ Many systems include CLI and GUI interfaces.
▪ Microsoft Windows is GUI with a CLI “command” shell
▪ Apple Mac OS X contains the “Aqua” GUI interface and a UNIX kernel and therefore the “shell”
▪ Solaris and Linux are CLI with optional GUI interfaces (Java Desktop, KDE)
▪ Which interface do you prefer?
26

OS interfaces
▪ CLI and GUI – interfaces for the user
▪ What are the other interfaces of the operating
system?
▪ Interface for programs that run on the computer and request services from the OS
• The system call interface
▪ Hardware interface
• Interrupts, drivers device controllers
27

Memory
Multi processor
Clusters
I/O Management
Device Controllers
Bus CPU
Structure Architecture Memory
interrupt Secondary DMA
Memory Main
One * processor
Hardware
I/O
Direct I/O
Structure
Organization
Computer System
Memory
Services What is it?
User Interfac GUI or CLI
Operating Management System
Operation
Dual Mode
Process
Memory Management
User View
28

Operating system operations
▪ The OS works on the basis of interrupts
▪ Interrupts come from hardware AND software
▪ Mouse click, divide by zero, OS service request
▪ Timer interruption (process time finished), memory access error (process wants to modify another one or the OS).
▪ Some operations will have to be done only by a reliable program.
▪ Access hardware, memory management registers.
▪ An evil user program could damage other
processes, steal the system, …
▪ Solution: operation in dual mode.
29

User mode and kernel mode
▪ Dual mode operation allows the OS to protect itself and other components
▪ User mode and kernel mode (or supervision)
▪ Bit mode is found in the hardware
• Distinguish the mode (user or kernel)
• Some instructions are privileged
• Call to OS changes the mode to kernel and the return of the call changes it to user mode.
30

Transition from user mode to kernel mode
▪ A timer prevents processes from taking over the system
▪ An interruption after a period of time
▪ OS decrements a counter
▪ When the counter is zero, change process or end process.
▪ Configure before giving control to the process to regain control or terminate the program.
31

The system call
▪ The interface that offers OS services to programs
▪ Process control:
• to run a program.
▪ File management:
• create / open / read / write a file, list a directory.
▪ Device management:
• request / release of a device
▪ Information management:
• time management, process attributes and files
▪ Communication:
• open / close a connection, send / receive messages
32

System call (continued)
▪ Normally written with high level programming language (eg C).
▪ Implemented with software interrupt
▪ The software interrupt changes the mode bit to kernel mode and calls the appropriate subroutine according to an array of system calls and the interrupt number
• Linux example: http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls
.html
▪ At the end of the subroutine, the mode returns to user mode and values ​​are returned to the calling program.
33

System call API
34

How to access system calls
▪ Often accessed through programs with an application programming interface (API) and not directly system call
▪ Common APIs:
▪ Win32 for Windows
▪ POSIX API for POSIX systems
• UNIX, Linux and MAC OS X
▪ Java API for Java Virtual Machine (JVM)
▪ The calling program does not know anything about the
implementation of the system call.
▪ Simply obeys API standards: parameters to provide, return values, and desired operation
▪ The OS interface details are hidden behind the API.
• Managed by the API library (set of functions supplied with the
compiler)
▪ Possible to use system calls directly 35

Example of the standard API in C
▪ The printf () function which makes a write() system call
36

Main
▪ Process management
▪ A process with a thread has a single program counter
▪ The OS manages the resources required by the processes
• CPU, memory, I/O, files
• Initialization data
▪ The OS manages the activities of the processes: creation and destruction, interactions between processes, etc.
▪ Memory management
▪ Memory management determines which process and when it occupies memory to optimize CPU usage and the computer’s response to users
▪ Secondary memory management
▪ The OS gives a uniform and logical view of the information stored
in secondary memory
▪ File system, mass storage
▪ The I/O subsystem
▪ A role of the OS is to hide the various peculiarities of the user’s
devices
operations
of the operating system
(OS)
37

Memory
Multi processor
Clusters
I/O Management
Device Controllers
Bus CPU
Structure Architecture Memory
interrupt Secondary DMA
Memory Main
One * processor
Hardware
I/O
Direct I/O
Structure
Organization
Computer System
Memory
Services What is it?
User Interfac GUI or CLI
Operating Management System
Operation
Dual Mode
Process
Memory Management
User View
Virtual Machine
Design Questions
Structure
38
Modules
Micro
Different Flavors
Layer kernel

realization
of OS
Design and
▪ The design of the SE is mainly affected by the choice of material and type of system
▪ Batch, time-shared, one-user, multi-user, distributed, real-time, general use
▪ User needs versus system needs
▪ User needs – easy to use, easy to learn, reliable, and fast
▪ System requirements – easy to design, simple to build and maintain, as well as flexible, reliable, error-free, and efficient.
▪ Implementation
▪ Traditionally in assembler
▪ Today, especially in C, with small sections in assembler (drivers, manipulation of registers)
39

System structure
▪ Internal structure of OS vary
▪ Since needs/requirements vary
▪ Simple hardware, simple functions ▪ Simple monolithic structure
▪ More resources and complex functions
▪ Layered Structure
▪ MS-DOS and traditional UNIX are monolithic OS which use a layered structure.
▪ Even more resources and functions, with a focus on flexible and elegant design
▪ Micro-Kernel structure (MACH, QNX, Windows NT)
▪ Flexibility and efficiency
▪ Modular structure (Solaris, Windows NT)
40

UNIX structure: few layers
41

Virtual machines: the problem and the solution
▪ How to allow different OS to run on a single physical machine?
▪ Not easy, because each OS requires direct access to the hardware
▪ SOLUTION: A program that creates a layer that makes several physical machines available virtual
▪ On each we can run a different SE 42

System model
(a) A single real machine and single kernel
(b)
Several
virtual
machines and
several
kernels
43

Operation
▪ The VM system allows unprivileged instructions to execute normally
▪ System calls are executed by the VM system and the results are passed to the virtual machine on which the process is running
44

Advantages
▪ Each virtual machine can use a different OS! ▪ In theory, we can build virtual machines on
virtual machines!
▪ Complete protection, because virtual machines are completely isolated from each other
▪ A new OS can be developed on a virtual machine without disturbing others
45

Implementations
▪ The concept of VM is widely used to allow running one OS on another
▪ Eg. SUN, Apple, Linux allow Windows to run on their platform,
▪ They must provide Windows with an environment that Windows recognizes as its usual Intel environment.
46

VMWARE on Linux
47

Java Virtual Machine
48

We do not cover these concepts
▪ Distributed system
▪ Embedded real-time systems ▪ Multimedia systems
▪ Hand held Computers
▪ Peer to peer
▪ WEB operating system
49
Fall 2008

Memory
Multi processor
Clusters
I/O Management
Device Controllers
Bus CPU
Structure Architecture Memory
interrupt Secondary DMA
Memory Main
One * processor
Hardware
I/O
Direct I/O
Structure
Organization
Computer System
Memory
Services What is it?
User Interfac GUI or CLI
Operating Management System
Operation
Dual Mode
Process
Memory Management
User View
Virtual Machine
Design Questions
Structure
50
Modules
Micro
Different Flavors
Layer kernel

Thank You!
متشکرم