• 沒有找到結果。

Contents jOWjTu{t Ttz

N/A
N/A
Protected

Academic year: 2022

Share "Contents jOWjTu{t Ttz"

Copied!
43
0
0

加載中.... (立即查看全文)

全文

(1)

資訊系統原理

郭大維教授

臺灣大學資訊工程系

Contents

?Computer Systems Overview

?Operating Systems Concept

?UNIX

?Other System Services

?Unified Modeling Language

?UML Introduction

?System Development Process

?Use Cases, Class Diagrams, etc.

(2)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Operating Systems Concept

?What is an operating system?

?Operating system architecture

?Process concept

?CPU scheduling

?Memory management

?File and I/O systems

?Networking

What is an operating system?

?What is an operating system?

?A package of software called OS!

Hardware Operating System Application Systems useruser user user user user

user

Kernel interface

System call

interface

(3)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

What is an operating system?

?A control program

?Control the execution of user programs

?Prevent errors/misuse

?An environment for efficient/ convenient usage of a computer system.

?A resource allocator

?CPU, memory space, file storage, I/O devices, shared code, data structures, etc.

What is an operating system?

?Terminology

?Multiprogramming

?CPU/job scheduling – short/mid/long-term

?Time-sharing

?Multiprogramming + CPU switching ~ interactivities

?Batch processing

?Job pool – with/without multiprogramming

?Spooling (Simultaneous Peripheral Operation On-Line)

?Printf -> buffer (memory/disks) -> printout at a printer.

?Card readers -> disks -> run process

(4)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Operating Systems Concept

?What is an operating system?

?Operating system architecture

?Process concept

?CPU scheduling

?Memory management

?File and I/O systems

OS Architecture

terminal controller, terminals, physical memory, device controller, devices such as disks, memory, etc.

CPU scheduling, signal handling, virtual memory, paging, swapping,

file system, disk drivers, caching/buffering, etc.

Shells, compilers, X, application programs, etc.

Kernel interface to the hardware System call interface

useruser user user user user

user

(5)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

OS Architecture

?What components/functionality it has?

?Process Management

?Creation/deletion/suspension/resumption of user/system processes

?A process is a program in execution.

?Process scheduling

?Mechanisms for process synchronization

?Interprocess communication mechanisms

?Memory Management

?Memory allocation/deallocation

?Paging/segmentation memory management

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 49-54

What is an operating system?

?File Management

?Creation/deletion of files/directories

?Mapping of files to secondary storage

?I/O Systems & Storage Management

?Hide the peculiarity of specific H/W devices from users

?Storage allocation and management

?Disk scheduling

?Networking

?Various networking service such as naming resolution

?Protection System

?CPU, Memory, I/O devices

(6)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

OS’s on Parallel/Distributed Systems

?Parallel Systems

?More than one processor in close communication, sharing of bus, clock, sometimes memory and peripheral devices –

tightly coupled systems!

?Symmetric/asymmetric operating systems.

?Distributed Systems

?More than one processor without sharing of memory or any clock – loosely coupled systems!

?Heterogeneous vs homogeneous systems!

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 14-17

Real-Time OS

?Why RTOS

?A convenient and reliable environment to develop time/safety-critical applications.

?Requirements – depending on applications!

?Predictability – Verifiability & interrupt latency

?Reliability - Strictness of Deadline Violations

?Reconfigurability - System Size and Functionality

?Efficiency of System Components - Time

Granularity, Threads, and Resource Management

?Variable Models of Task Communication -

(7)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

What is an operating system?

?Roadmap

?Booting

?I/O Structure

?Storage Hierarchy

?etc

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 24-30, 35-37

Computer System Architecture

CPU

cache

memory controller

memory

disk controller printer

controller

printer

(8)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Booting

?Bootstrap program

?Initialize all aspect of the systems

?E.g., CPU registers, device controllers, memory, etc.

?Load OS, and Run it!

?Run init to initialize system services

?Start virtual memory, various daemons, login processes, etc.

I/O Structure

?Parallelism of CPU and I/O activities

?Interrupts

I/O device

Process running on a CPU executing

transferring idle

I/O request I/O request

done

Process execution interrupt

Interrupt handler

return

Process execution

Save Return Trace!

(9)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

I/O Structure

Bottom Half Top Half processes User

Space OS

System call interface

system calls, e.g.

READ/WRITE

device drivers

hardware

time

interrupt Interrupt handler

data transfer

* Parallelism of multiple process executions!

?? Could OS return control to the process sooner??

•Synchronous I/O, e.g., reads

•Asynchronous I/O, e.g., writes

I/O Structure

?Interrupt types:

?Software interrupts (traps)

?Signals, division-by-zero, etc.

?Hardware interrupts

?Service requests of I/O devices, etc.

?Servicing of interrupts

?Generic handler

?Interrupt vector (UNIX)

?Masks, Disabling, Enabling

Handler_a() {

… ..

} bits to mask interrupts

(10)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

I/O Structure

?Device Status Table

Printer 1 Status: idle Disk 1 Status: Busy

… ..

File:XX Offset:yyy Size:zzz

File:KK Offset:iii Size:jjj

Process execution

Waiting for I/O completion

Synchronous behavior!

I/O Structure

? DMA (Direct Memory Access)

? Release CPU from handling excessive interrupts

? e.g., a high-speed device:

? 2us service / 4us

? Procedure, e.g., WRITE

1. Use device driver to set up the registers of the DMA controller.

2. DMA moves blocks of data between memory and its own buffers.

3. Transfer from its buffers to its devices 4. Interrupt the CPU

Until done

(11)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Storage Hierarchy

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 24-30, 35-37

registers cache main memory

electronic disks (battery) + others, e.g. flash magnetic disks

optical disks tapes

tertiary storage systems

CPU can directly access them!

nonvolatile storage

removable media

* Media – disk, Device – disk drive, System – device + controller + software

I/O and Storage Systems

?Cost/bit vs Capacity/dollar vs volatility

?Device I/O

?Memory-Mapped I/O

?For devices with fast response time

?Program I/O (PIO)

?polling

?Interrupt-Driven I/O

(12)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Storage Hierarchy

?Caching

?When an information is used and might be used again, it is cached at a faster storage system.

?Strategies at different levels?

?Buffering

?When an information is “pushed” out to a slower storage system, it is buffered at a faster system for later actions.

?Relationship with caching?

Storage Hierarchy

?Coherency and Consistency

?Vertical information flow

?“Horizontal” information flow

CPU

Memory disks

CPU Memory

disks

(13)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Dual Mode Protection

?What is “dual mode”?

?User mode

?Kernel mode

?Privileged instructions, such as I/O, memory-setting related instructions

?Rationale

?Only execute privileged instructions at the kernel mode to protect errors and misuse!

?Requirement

?Hardware support

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 39

Add R3, R4 SYS 23 ADD R5, R4

SysCall() {

… . }

Booting - Revisiting

?Bootstrap program – Kernel and Single User Mode

?Initialize all aspect of the systems

?E.g., CPU registers, device controllers, memory, etc.

?Load OS, and Run it! – Kernel and Multi-User Mode

?Run init to initialize system services

?Start virtual memory, various daemons, login processes, etc.

?Shell Processes – User and Multi-User

Mode

(14)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

I/O Structure Revisiting

Bottom Half Top Half process User

Mode Kernel Mode

System call interface

system calls, e.g.

READ/WRITE

device drivers

hardware

time

interrupt Interrupt handler

data transfer

* A bit in PSW of CPU to distinguish user or privileged instructio ns!

Operating Systems Concept

?What is an operating system?

?Operating system architecture

?Process concept

?CPU scheduling

?Memory management

?File and I/O systems

(15)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept

?Process

?An active entity

?The corresponding passive entity

?Program code

new

ready

running waiting

zombie

fork

scheduled

interrupt exit

I/O or event waiting completed

stop

suspend resume

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 89-97, p 126.

Process Concept

?Process Image in Memory

?System Resources

? Program Counter (PC)

? Process Status Register

? Stack Pointers (sp)

? Memory

? etc.

Code Segment Data Segment

PC heap

user stack argv, argc,…

sp

(16)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept

?Process Control Block Struct PCB {

char p_pid;

char p_pri;

char p_ppid;

int pc; /* program counter */

int rq_former, rq_next; /* for ready queue*/

int files[NFILE];

} PCB[NPROC];

• major queues:

• I/O queues

• ready queue

Process Concept

Process i OS Process j

Save state into PCB[i]

..

Load state from PCB[j]

Save state into PCB[j]

Load state from PCB[i]

.. .. ..

Interrupt or system call

Interrupt or system call

dispatch

(17)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Scheduling

?A Ready Queue

Priority -decreasing

0 1 2

PCBi PCBj

PCBk

• Select the highest-priority process to run and de-queue it!

• Hook the running process back to the ready queue!

Context Switching

– Necessary Overheads for Multiprogramming

?Def.

?Switch the CPU from one process to another process

?Save the state (or called context) of the running process

?Reload the state of the ready process

?Context Switching Time

?Hardware-dependent!

?Multiple register sets!

?Special hardware instructions!

(18)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept

?Kernel-Supported Thread

?A program counter

?A register set

?A stack space

?User-Level Thread

Code Segment Data Segment

user stack sp1

PC1 user stack sp2

PC2

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 103

OS

A process with one kernel-supported thread

Process Concept

?Thread – Lightweight process

?An ordinary process contains one thread!

?Types

?Kernel-Supported Threads

?User-Level Threads

OS OS OS

Ordinary process 3-kernel-supported 3-user-level

(19)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Operating Systems Concept

?What is an operating system?

?Operating system architecture

?Process concept

?CPU scheduling

?Memory management

?File and I/O systems

CPU Scheduling

?Scheduling Criteria

?CPU Utilization

?Throughput =

Number -of-Completed-Processes

/

Sec

?Turnaround Time

?Completion time – Submission time

?Waiting Time

?Time spent in the ready queue

?Average vs Worst-Case vs Combination

?variance

(20)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

CPU Scheduling

?First-In-First-Out (FIFO) Scheduling

?Select the first process in the queue for execution!

?“Fair” but lengthy waiting for urgent processes! -> Shortest Job First??

PCBi … ..

Ready Queue

PCBjPCBk PCBa

CPU Scheduling – FIFO

? Processes Burst CPU Time Arrival Time

P1 24 0

P2 3 1

P3 3 1

0 24 27 30

Average Waiting Time = (0 + 23 +26) / 3

(21)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

CPU Scheduling

?Priority-Driven Scheduling

Priority -decreasing

0 1 2

PCBi PCBj

PCBk

• Select the highest-priority process to run and de-queue it!

• Hook the running process back to the ready queue!

• Starvation problem?!!

Ready Queue

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 133-137.

CPU Scheduling – Priority

? Processes Burst CPU Time Arrival Time Priority

P1 24 0 3

P2 3 1 2

P3 3 1 1

0 1 30

Average Waiting Time = (6 + 0 +3) / 3

4 7

(22)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

CPU Scheduling

?Round-Robin Priority-Driven Scheduling

? N processes, quantum = ? , (N * ? ) cycle time!

? How small ? should be? Any limitation?

Priority -decreasing

0 1 2

PCBi PCBj

PCBk Ready Queue

Run CPU for a “time quantum” (time slice), e.g. 10ms

Pop

Insert here or at a lower priority

CPU Scheduling – RR

? Processes Burst CPU Time Arrival Time Priority

P1 24 0 1

P2 3 1 1

P3 3 1 1

0 2 30

Average Waiting Time = (6 + 5 +6) / 3

4 6

Quantum = 2

8 9 10

(23)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

CPU Scheduling

Bottom Half Top Half processes User

Space OS

hardware

Timer expires to

• Expire the running process’s time quota

• Keep the accounting info for each process

System calls such as I/O req which may cause the releasing CPU of another process!

Process Concept - Revisiting

Process i OS Process j

Save state into PCB[i]

..

Load state from PCB[j]

Save state into PCB[j]

Load state from PCB[i]

.. .. ..

Interrupt or system call

Interrupt or system call

dispatch

(24)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Operating Systems Concept

?What is an operating system?

?Operating system architecture

?Process concept

?CPU scheduling

?Memory management

?File and I/O systems

Memory Management

?Logical address vs Physical Address

CPU

Logical Address for Instructions or Data

Memory Management

Unit

Physical Address

Process Image Memory Process

Image

PC

(25)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Memory Management

?Contiguous Allocation

?Single Partition

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 249-264.

The User Process Memory

OS

CPU

Memory Management

Unit

If logical -address < Limit-Register Then

physical-address = logical address + Relocation -Register Else

Signal the user process!

Limit-Register Relocation-Register

345

10000

10345

5000

Memory Management

?Contiguous Allocation

?Multiple Partitions

P1 OS

400K

1000K

P2

2000K P3

2300K 2560K

P1 OS

400K

1000K

P4

2000K P3

2300K 2560K 1700K -P2+P4

P5 OS

400K

1000K

P4

2000K P3

2300K 2560K 1700K -P1+P5

900K

(26)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Memory Management

?Contiguous Allocation

?Multiple Partitions

?First-Fit

?Best-Fit

?Worst-Fit

?Fragmentation

?External

?Internal P5

OS

400K

1000K

P4

2000K P3

2300K 2560K 1700K

900K P5

OS

400K

P6

2300K 2560K 1700K 900K

Next request is for 819000B, i.e., 800KB-200B

Memory Management

?Solutions to Fragmentation

?Compaction

P5

400K OS

1300K

P4

2000K P3

2300K 2700K 1700K 1000K

P5

400K OS

1400K P4

P3

2700K 1700K 1000K

P5

400K OS

P4

2000K P3

2300K 2700K 1000K

P5

400K OS

1300K

P4 P3

2700K

1700K

1000K

(27)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Memory Management

?Paging – Another solution to external fragmentation!

Page 0 Page 1 Page 2 Page 3

Frame #

Page 0

Page 2 Page 1

Page 3

7 3

3 2

4 1

1 0

Frame # Page #

0 1 2 3 4 5 6

logical 7

memory

physical memory A page

table for each process

Paging

? Address Translation

page number offset

p bits d bits

frame number offset

f bits d bits

F

P D

Logical Addr.

P

F D

(28)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Paging

Page 0 Page 1 Page 2 Page 3

physical address

Page 0

Page 2 Page 1

Page 3

111 11

011 10

100 01

001 00

F P

00000 00100 01000 01100 10000 10100 11000 11100

logical memory

physical memory page

table

P D

2 bits 2 bits

F D

3 bits 2 bits

0000 0100 1000 1100

01 10 100 10

Paging

Page 0 Page 1 Page 2 Page 3

physical address

Page 0

Page 2 Page 1

Page 3

111 11

011 10

100 01

001 00

F P

00000 00100 01000 01100 10000 10100 11000 11100

logical memory

physical memory page

table

0000 0100 1000 1100

1100 A 1101 B 1110 C

Page 3

11100 A 11101 B

Frame 7

(29)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Paging

?Hardware Support for Paging

?Registers as Page Tables

?Memory-Resident Page Tables

?Translation Look-aside Buffer (TLB)

F

P D

P

F D

P F

TLB

Paging

? Paging-TLB

?TLB Hit

?Access time = TLB-access-time + Inst/Data- Memory -Access

?E.g., 20ns + 100ns

?TLB Miss

?Access Time = TLB-access-time + Page- Table-Memory-Access + Inst/Data-Memory- Access

?E.g., 20ns + 100ns + 100ns

? Hit Ratio 80%

?Effective access time = 20ns + 100ns +

0.2 *100ns = 140ns

(30)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Virtual Memory

?Definition

?A technique that allows the execution of

processes that may not be completed in memory.

?Swapping

?Process image may reside in the backing store rather than swap the entire image in.

?Page fault: occurs when program references a non-memory-resident page.

?Thrashing

?A process is spending more time in page faults than executing.

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 289,291-293,317.

Context Switching-Revisiting

?Def.

?Switch the CPU from one process to another process

?Save the state (or called context) of the running process

?Reload the state of the ready process

?Context Switching Time

?Hardware-dependent!

?Multiple register sets!

?Special hardware instructions!

(31)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept-Revisiting

?Process Control Block Struct PCB {

char p_pid;

char p_pri;

char p_ppid;

int pc; /* program counter */

int files[NFILE];

} PCB[NPROC];

Operating Systems Concept

?What is an operating system?

?Operating system architecture

?Process concept

?CPU scheduling

?Memory management

?File and I/O systems

(32)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

File System

?Provides a mechanism for on-line storage of and access to both data and programs

?Components

?Files: logical unit abstracted by the OS.

?A directory structure: special files to organize and provide information to files.

?Implementation Issues

?File storage

?Disk space allocation, free-space recovery, etc.

?File access

?Direct/sequential access, protection, etc.

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 337-342,346-348.

File System

?What should be considered?

?File attributes such as name, file operations such as seek, file types such as executable, file structures such as those for Word.

?File System Structure

?File systems usually reside on block- oriented devices – block transfer

?Characteristics

?In-place update

?Any given block can be accessed directly.

(33)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

File System

?File Attributes

?Name, type, (disk) location, size, protection, modified/created time/date, user/group ID, etc.

?File Operations

?Create, write, read, reposition, delete, truncate.

?File Structure

?File: free form – a sequence of bytes in UNIX

?Directory: a structured file in UNIX

File System – File Type

? Why file type?

?OS can recognize a file and operate on it in a proper way.

? Common Tecniques

?Include the type as a part of the name:

? Executable . Exe, .com, .bin

? Object .obj, .o

?Read information such as creators in file attributes

?UNIX – store a crude magic number at the file beginning

* In many cases, extensions are only considered as hints.

(34)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

File System – File Structure

?Approaches

?A minimum number of file structures

?UNIX – flexible but with limited support

?The file structure for executables must be supported

?A number of file structures and special operations

?No support of file structures requireed by new applications

?Large OS size!

File System

?File System vs I/O System vs Device

File System

I/O System

Devices

See directories with a root and files!

See a collection of logical blocks with continuous numbers!

drivers &

interrupt handlers

Mapping of logical blocks to physical blocks

Mapping of each file to a set of logical blocks Provide a directory structure

physical blocks

(35)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

File Systems

?File Methods

?Sequential Access

?Basic Operations

?READ, WRITE + file pointers

?Direct Access

?Basic Operations

?READ N or Write N, where N is the relative block number.

File: a sequence of bytes … ..

a sequence of (logical) blocks

File System –

A UNIX Approach

?Process Control Block Struct PCB {

char p_pid;

int pc; /* program counter */

int files[NFILE];

} PCB[NPROC];

Read(4, … )

Tables of Opened Files (per process)

System Open File Table

In-core i-node list

i-node i-node

i-node

sync

data block data block

kernel space user space

open create an entry

(file current position, etc)

file-open-count++ Load the corresponding

i-node if it is absent.

(36)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

File System –

A UNIX Approach

?Process Control Block Struct PCB {

char p_pid;

int pc; /* program counter */

int files[NFILE];

} PCB[NPROC];

Read(4, … )

Tables of Opened Files (per process)

System Open File Table

In-core i-node list

i-node i-node

i-node

sync

data block data block

kernel space user space

read/write adjust the current file position - offset

Modify the corresponding in-core i-node structure if needed.

* When the file is closed, and file-open-count = 0, then the disk-resident i-node should be modified!

BSD UNIX i-node

mode owner timestamp size block ref-count

triple indirect double indirect

single indirect

direct blocks

data data data

data data data

data data

… data …

• 4KB block size

• 12 direct pointers

• 48KB

• 1 single indirect

• 4-byte block ptr

• 1K * 4KB = 4MB

• >> 4GB for the largest file!

(offset = 32 bits, 4G=2 32 )

(37)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Memory-Mapped File

?Allow a part of the virtual address space to be logically associated with a section of a file.

1 2

Virtual Memory for Process A

1 2

Virtual Memory for Process B

Physical Memory

1 2 3

FileA:

File System – Directory Structure

?Partition (/Volume):

?a low level structure in which files and

directories reside.

?Directory:

?Records info for “all”

files on a partition.

directory files directory

files

… disks

partition

partition

(38)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

File System

– Tree-Based Directory

? Path name

?Specify a file by listing “node”names from the root to the corresponding node in the structure

?/users/userA/info-sys/test vmunix

/

dev

console lp0 …

bin

csh …

lib

libc.a …

usr

include …

etc

passwd …

File System

– Tree-Based Directory

? Path name

?Absolute path name

?Begin at the root

?/usrs /usrA/fileA

?Relative path name

?Begin at the current directory

?usrA/fileA

? Path Names vs Devices

?Mixing of device names and directories – MS DOS/Windows

?C:/mine/ntu/mail

?No distinguished features – A UNIX approach

(39)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Sharing of Files

?Hard Link

?Each directory entry creates a hard link of a filename to the i- node that describes the file’s contents.

?Symbolic Link (Soft Link)

?It is implemented as a file that contains a pathname.

?Example: Shortcut on Windows

foo

bar

/usr/joe

/usr/sue File i-node:

Reference = 2

foo

bar

/usr/sue

File i-node:

Reference = 1

/usr/joe

File i-node:

Reference = 1 data file:

/usr/joe/foo

* Problem – infinite loop in tracing a path name with symbolic links – 4.3BSD, no 8 passings of soft links

* Dangling pointers

File Systems - Mounting

?(name of the device, mount point)

tmp

Use an appropriate device driver to read the device directory and verify the format => mount!

•Mount point: the location within the file structure at which to attach the file system.

•A bit in the i- node indicates that

whether a file system is mounted

on it! -> find the i- node of the

UNIX: manual mounting

(40)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Protection

?Major concern for information storage

?Reliability – prevent physical damage

?Information Duplication!

?Protection – prevent improper access

?Access Control!

Protection

?How to prevent improper access?

?Access control!

?Read, Write, Execute, Append, Delete, List, etc

?Approaches:

?Complete isolation

?No protection at all

?Controlled access by limiting the “types” of

file access based on some factors:

(41)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Protection

?Access user list for each file/directory

?{ < user-ID, allowed access types> … }

?Tedious in maintenance and variable directory sizes -> condense such info (UNIX)

?Read/write/execute over owner/grp/others

?Issues

?Control in group memberships

?Membership per user?

?A password for each file/directory

?A large number of passwords

?Different passwords for different levels of protection?

Operating Systems Concept

?What is an operating system?

?Operating system architecture

?Process concept

?CPU scheduling

?Memory management

?File and I/O systems

(42)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

I/O Subsystems

?Why?

?Provide the simplest interface to the rest of the system

?Optimize I/O for the maximum concurrency

?Variations:

?Block vs Character I/O

?Sequential/Random Access

?Synchronous/Asynchronous Transfer

?Dedicated/Share

?Read-Only/Read-Write

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 398, 408-410, 414-415.

I/O Subsystems

?Conflicting trends

?Increasing standardization of software/ hardware interfaces

?Increasing broad variety of I/O devices

?Device drivers which provide a uniform device-access interface to the I/O subsystem.

?How the I/O system improves the efficiency of the computer?

?Schedule I/O operations, e.g., those on disks.

?Use techniques such as buffering, caching, or

spooling.

(43)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

I/O Subsystems

?Approaches

?Abstraction – interface

?Encapsulation – device drivers

Various controller, such as SCSI controller Various devices, such as disks, mouse

OS Various drivers System Calls

Principles in Doing I/O

?Reduce the number of context switches.

?Reduce the number of data copyings.

?Reduce the frequency of interrupts

?Large transfer, smart controller, etc.

?Increase concurrency

?DMA controller

?Move processing primitives into hardware.

?Balance CPU, memory subsystems, bus,

and I/O memory.

參考文獻

相關文件

Tei-Wei Kuo, Embedded System and Wireless Networking Lab, National Taiwan University.. Real-Time

 civilian life and opportunities ©2011 Yen-Ping Shan All rights reserved

4 理律法律事務所 © 2020 All rights

All rights reserved.. 1

All rights reserved.... All

* All rights reserved, Tei-Wei Kuo, National Taiwan University,

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005..

* All rights reserved, Tei-Wei Kuo, National Taiwan University,