CS代考 COMP 2432 2021/2022

Operating Systems
Lecture 1 Introduction to Operating Systems

 OS and Computer System  The Operating System

Copyright By PowCoder代写 加微信 powcoder

 Components of OS
 Other aspects of OS
 OS Services
COMP 2432 2021/2022

What is an Operating System?
 What do you have in mind when asked about an Operating System?
 Windows 11
 Windows 3.1
 Windows Mobile  X-windows
COMP 2432 2021/2022

What is an Operating System?
 What is a computer?
 COMP 2421 / COMP 1411
 A box containing CPU, with a keyboard, a mouse and a monitor.
 How do you use a computer?
 Sit in front of the keyboard to type in something, or use the
 What is the magic from your action of mouse clicking to really using the computer to do something?
 Some one sits between you and the computer.  It is the manager of the computer system!
mouse to click around?
COMP 2432 2021/2022

What is an Operating System?
 The operating system (or OS) is the manager.
 It is the manager to the whole computer system.  Manager to home:
 Manager to company:
 Manager to university:
 A manager (non-line staff) should ensure efficient operation of the home, company, university etc.
 OS goals:
 Execute user programs to solve user problems.  Make the computer system convenient to use.
 Use the computer hardware in an efficient manner.
COMP 2432 2021/2022
 Manager to yourself:
 A computer system contains the hardware (COMP 2421),
programs (COMP 1011/2011/2021) and users (you).
 OS is the program that acts as an intermediary between a
user and the hardware.

The Computer System
 A computer system contains four components.
 Hardware
 Provide basic computing resources.  CPU, memory, I/O devices.
 Operating system
 Control and coordinate use of hardware among various
applications and users.
 Windows 11, OS X, Unix, Linux.
 Application programs
 Define the ways that system resources are used to solve user
computing problems.
 Word processors, compilers, web browsers, database systems, video games.
 People, devices, other computers.
COMP 2432 2021/2022

The Computer System
COMP 2432 2021/2022

Computer System Operation
 At the hardware level, one or more CPUs and device controllers are connected through common bus to access shared memory.
 Concurrent execution of CPU and devices are competing for access to memory (memory cycles).
COMP 2432 2021/2022

The Operating System
 A manager should
 Allocate and manage company resource effectively.
 Control working of subordinates so that they deliver performance.
 An operating system is
 A resource manager
 Manage the allocation of computer resources.
Decide between conflicting requests for efficient and fair use of resource.
 A control program
Control execution of programs to prevent errors and improper use of computer.
COMP 2432 2021/2022

The Operating System
 At the foundation of all system software, it performs basic tasks such as controlling and allocating memory, prioritizing system requests, controlling input and output devices, facilitating networking, and managing files.
 Drawing the OS boundary
 Everything a vendor ships when you buy an OS.  Windows, VMS, Multics
 The one program that is running at all times on computer.
 It is often called the kernel (central part or core).
 Everything other than the always executing kernel is either a system program (shipped with the OS) or an application program (written by other programmers).
 Unix or Linux.
Question: Do you think Internet Explorer to be part of OS?
COMP 2432 2021/2022
 Definition from Wikipedia
 A computer program that manages the hardware and
software resources of a computer.

The Operating System
 Four important components within OS.
 Processor manager  Memory manager  File manager
 Device manager
 These components interact with one another.
 User command interface
COMP 2432 2021/2022
 Generic issues like protection and security
They also interact with and are controlled by users.

The Operating System
 Processormanager
 Handle jobs within system to be executed by CPU (processor).
 Memorymanager
 Allocate the memory to be used by jobs.
 Filemanager
 Provide systematic storage for permanent data or programs.
 Devicemanager
 Control the different devices, mostly physical I/O devices.
COMP 2432 2021/2022

The Operating System
 Resource manager
 OS must manage the use of resources by users.
 Processor or CPU, memory, file, device are all resources.
 The presence of a user in the OS could be represented by a task or a process.
 When a user or several users submit many tasks, what resources are allocated to them?
 Could you open Windows media player and RealPlayer together? Will you hear mixed sound?
 Could the printer be shared by two users simultaneously?  Control program
 OS should control to avoid bad things. If bad things happen, OS should try to recover.
 Windows could produce a blue screen or crash and reboot.
COMP 2432 2021/2022
 Such a task or process will need to use resources.
 A process will consume CPU time, use up memory to execute,
read inputs from a file and send outputs to a printer.

Process Management
 Processor manager performs process management.
 A process is a program in execution.
 Program is a passive entity. You write a program to be executed.
 Process is an active entity. You run a program to create a process.
COMP 2432 2021/2022
 The same program could create multiple processes.
 For example, you could invoke multiple copies of IE at the
same time to browse different web pages.
 A process needs resources like CPU, memory, files to perform its functions.
 A process executes its program instructions sequentially, one at a time, until completion.
 A completed process will return resources that it has taken (or forced taken back).

Process Management
 A typical computer system has many processes running concurrently.
 If there is one CPU, how can many processes be run concurrently?
 In Windows 3.1 or MS-DOS, only one process can be executed at any moment.
 In Windows 11, OS X, Unix or Linux, CPU is shared between many processes.
 You take several subjects in the same semester and are doing several assignments that are due the same week. How can you do that?
 This is called multiprogramming.
 When a process is using the CPU, another process may be waiting for the user to input some data. Yet another process is printing to a printer.
COMP 2432 2021/2022
A process could use CPU for one second, then passes it to next process.

Process Management
 OS is responsible for several process management activities.
 Create and terminate processes.  Suspend and resume processes.
A process waiting for user to type something could go to sleep.
 Allow for process communication.
 A process may need to pass some data to another.
 Allow for process synchronization.
A process may need to wait until another process gets the data.
 Handle deadlocks.
A process may be waiting for another process, but that other process may be waiting for the first process.
COMP 2432 2021/2022

Memory Management
 Memory manager performs memory management.
 Data should be in memory when a process is executing.
 Instructions of the program for a process should be in memory for execution.
 Memory management controls when and what data or program code should be in memory.
This is important if the memory is not sufficient to hold all useful data and program code.
 Data and program are loaded into memory when necessary.  They will be removed from memory when no longer needed.
 OS must keep track of the usage of memory.
 Data for two different users should not be put in the same
 Only one copy of the same program (e.g. IE/Chrome) used by two users is needed in memory.
should be removed.
COMP 2432 2021/2022
memory location.
 If there is not sufficient memory, some less important data

Storage Management
 File manager performs storage management.  Storage (disk or tape) is controlled by its device
 Devices have different device features, e.g. speed, capacity, data-transfer rate, access method (sequential or random).
For example, a tape must go from the beginning to the end, and a disk can begin anywhere in the middle.
 Storage that a user could use is often generalized into a file.
 A user of a file does not need to concern with the speed or storage method.
A file stored on a tape and a file stored on the disk can
be accessed in a similar fashion, except for the time needed to get the file. COMP 2432 2021/2022
(disk / tape drive).

Storage Management
 File system
 Files are often collected and managed under a file
 Files are organized into directories.
 Each directory is a collection of related files.
For example, all your files for COMP 2432 can be collected under one directory and all files for COMP 2322 can be collected under another directory.
 OS provides operations on file system.  Create and delete files and directories.
 Open files for reading or writing.
 Map files onto secondary storage.
which file. COMP 2432 2021/2022
 Backup files to cater for system crash and storage failure.
 Provide access control to determine who can access

I/O Subsystem
 Device managers control and manage different devices.
 Devices are typically I/O devices (keyboard, mouse, monitor, disk), mass-storage devices (tape, disk), or communication devices (network card).
 OS should hide variations and details of hardware devices from the user.
 I/O subsystem provides management functions for I/O devices.
 Memory management concerning devices.
 Buffering (storing data temporarily while it is being transferred).
 Caching (storing parts of data in faster storage for better performance).
 Spooling (overlapping output of one job with input of another).
 Provide a general device-driver interface.
 Provide drivers for specific hardware devices. COMP 2432 2021/2022

Mass-Storage Management
 Mass-storage devices provide backup for data that does not fit in main memory or data that must be kept for a “long” period of time.
 Compare storing your data in local hard-disk versus over the internet (yahoo! or Google gmail) and you will see that speed of computer operation depends on speed of mass-storage.
 In OS, the system performance depends a lot on an efficient disk or secondary storage subsystem.
 OS activities on mass-storage:
 Free-space management: used and free disk clusters.
 Storage allocation: which part to be used to store a file.
 Disk scheduling: movement of the disk head and arm.
Question: why it takes quite some time for each user to log in the PC system when the lab begins?
COMP 2432 2021/2022

User Command Interface
 To connect a user to OS, there should be an interface.  Through the interface, the user must be able to issue
command to the OS.
 OS accepts commands and performs tasks according
to user need.
 Two major types of interfaces:
 Batch interface: commands are stored in a file (script file or *.bat file) before hand.
 Interactive interface: commands are issued on the fly by users. There are two types of interactive interfaces:
 Command line interface (CLI)  Graphical user interface (GUI)
COMP 2432 2021/2022

User Command Interface
 Command Line Interface is very simple.
 Allow direct command entry to the system with a text line.
 Could be implemented in kernel (dir) or as system programs (format).
 Several implementations with similar functionalities may exist for user choice.
 Example: different Unix or Linux shells.
 It is a program that loops to receive a command from user.
COMP 2432 2021/2022
 Interpret the command and execute it.
 A built-in command is one that is implemented in kernel (dir
in DOS or cd in Unix).
 A non-built-in command is just the name of a system
program (format.com or lpr – Unix command for print).  Command prompt in Windows or MS-DOS.

User Command Interface
COMP 2432 2021/2022
 Graphical User Interface is much more user-friendly.  It is a desktop interface, involving mouse, keyboard, and
monitor to support What You See Is What You Get.
 Icons represent files, programs, actions, etc.
 Moving mouse over objects with/without clicking in the interface cause various actions.
Provide information, select options, execute function, open directory or file.
 Many current systems provide both CLI and GUI.
 Windows is GUI based, with CLI “command” shell.
 OS X provides GUI interface with Unix/Linux kernel underneath and CLI shells available.
 Sun Solaris and Red Hat Linux are CLI with optional GUI interfaces (X-windows, CDE).
 How do you like the iPhone/iMac interface?

Protection and Security
 Other common functions needed of OS include protection and security.
 Protection
 A mechanism for controlling access of processes or users to
 Provide ways for users to specify the control and to enforce it.
 Security
 The defense of the computer system against internal and
Types of attacks: worms, viruses, denial-of-service, identity theft, theft of service.
OS can only protect against some of the attacks. Others should be managed by human.
 For example, if you give away passwords easily, the OS cannot protect you, but the use of biometrics may help.
resources defined by the system.
external attacks.
COMP 2432 2021/2022

Protection and Security
 Systems generally first distinguish a user from another user.
 It might be a role (TA) from another role (student).
 Depending on who a user is, different privileges on data or resource are given (who could do what).
COMP 2432 2021/2022
 Users are associated with unique user IDs (or security IDs).  The user ID is then associated with all files and processes of
that user to determine access control.
 Group IDs allow sets of users to be defined and control
shared access to processes or files.
 All students may access subject syllabus file, but not the
solution manual, while all instructors could access both.
 Special mechanisms should be provided for a party to grant
access privilege to another party.
 A lecturer could grant the privilege to a TA to access the solution manual.

Presence of Internet
 Resources include hardware, software and data.
 Hardware: CPU, memory, disk space.
 Software: programs, services, apps.
 Data: music, video, photos. COMP 2432 2021/2022
 We are in the Internet Era.
 There is no network component in the 4-
component plus one interface model.
 How should the network be integrated?
 We add one more component.  Network manager.
Allow computers to communicate with each other.  Need to define network protocols.
Provide a convenient way for users to share
resources while controlling access to them.

Network Management
Network Manager
(network communications, protocols, etc)
 Network operating system.
 Add the networking capability to an operating system.
 Unix allows you to write programs to communicate with another program on another computer.
 Distributed operating system.
 Users do not see the existence of the network.
 Services and data are just transparent with respect to location and access. COMP 2432 2021/2022

Network Management
 Network OS example:
 Unix, Linux, Windows 11.
 Distributed OS example:
 Data sharing via Google Drive or iCloud.  Why can you access to data elsewhere?
 Who is going to protect your data?
 How can you protect yourself?
 Whose data is it anyway?
COMP 2432 2021/2022

Operating System Services
 Let us summarize the functions or services provided by an operating system to help users.
 User command interface
Almost all operating systems have a user interface for users to specify the command or action to be done.
Interface could be Command-Line Interface (CLI) or Graphics User Interface (GUI).
Older systems (IBM 360/370) provide only the batch interface (JCL or Job Control Language).
 Program execution
The system must be able to load a program into memory and to run that program, and to complete the execution (may be normal completion or abnormal completion, indicating error).
COMP 2432 2021/2022

Operating System Services
 I/O operations
 A process may require I/O and the system
should support access to the I/O device.  File-system manipulation
 A process may need to read and write files and directories, create and delete them, search them, get file information, access permission management.
COMP 2432 2021/2022

Operating System Services
 Communications
 Processes may need to exchange information, on the same computer or between computers over a network.
 This is called interprocess communication.
 A network manager may be needed.
 Error detection
 OS needs to be constantly aware of possible errors, which occur in CPU and memory, in I/O devices, in user program.
For each type of error, OS should take the appropriate action to ensure correct and consistent computing.
 Parity bit, error correction code, RAID disk.
COMP 2432 2021/2022

Operating System Services
 Operating system also provides these functions to improve system efficiency.
 Resource allocation
 When multiple users or processes are running concurrently,
resources must be allocated to each of them.  Accounting
 To keep track of which user uses how much and what kinds of computer resources.
 Protection and security
 The owners of information stored in a multi-user computer
system would want to control the use of their information.
 Protection ensures that access to system resources is controlled.
 Security requires user authentication and defense of external I/O devices from invalid access attempts.
COMP 2432 2021/2022

 OS and Computer System  The Operating System
 Components of OS
 Other aspects of OS
 OS Services
COMP 2432 2021/2022

Operating Systems
Lecture 2 Interrupts and System Calls

 I/O processing
 Interrupt processing
 OS operation
 System calls and system programs  OS types and structures
COMP 2432 2021/2022

Operating System Mechanism
CPU and make decision and arrangement to control the system. COMP 2432 2021/2022
 Operating system is the manager of a computer system.
 Remember that OS is itself a program and that a process is a
program in execution.
 So OS will present itself as one or more processes in the computer
 When there are multiple processes executing, how can the OS control and manage them?
 What will you do when you have multiple assignments due tomorrow, or there are several dishes to cook for dinner?
 You could do one after the other. When you face problem with one, you may post a discussion note to BlackBoard and switch to another.
 You need a mechanism to be notified of special events, e.g. a new note on BlackBoard, or a phone call for a discussion on a project.
 The OS relies on a special alarm system, called the interrupt processing mechanism.
 When an interrupt occurs, there is a chance for OS to grasp the

I/O Processing
 One can perform I/O when CPU is doing useful work .
 When I/O is completed, OS needs to put aside its current work and looks at I/O device for next I/O.
 The event that I/O is completed causes an interrupt.
 The suspension (interruption) of current work to handle the event is called interrupt processing.
time COMP 2432 2021/2022

I/O Processing
 Two methods for I/O processing  Synchronous
 Asynchronous
Synchronous Asynchronous
COMP 2432 2021/

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com