You are on page 1of 10

CHAPTER 1: PLATFORM TECHNOLOGIES v. Operator carries Output Tape to Tape Reader.

vi. Tape Reader prints output.


Hardware + Software + Networks = Platform

HIERARCHY
MODERN COMPUTERS
I. Peopleware – Us
II. Software – serves as the platform for the A modern computer consists of:
hardware
o One or more processors
III. Hardware – physical aspects
o Main memory
TWO TYPES OF SOFTWARE: o Disks
o Printers
 Application Software
o Various input/output devices
 Multimedia
 Enterprise o AVR, mouse, keyboard, system unit, monitor, etc.
 Productivity • Managing all these components requires a layer of
 Educational software — the OPERATING SYSTEM

 System Software
 Operating System HARDWARE ARCHITECTURE – A set of disciplines that
 Driver’s/Device System describes a computer system by specifying its parts and
 Utility System their relations provides physical environment.

Common Types:
PLATFORM o Commodity computing platforms
 In general, a computing platform is any pre-existing o Video game consoles
hardware environment, a piece of software that is o RISC
designed to run within it, and any associated facilities o Midrange computers
used with it. o Mainframe computers
 A platform is any base of technologies on which other o Supercomputer
technologies or processes are built; support the
creation of other technologies
 Most services that the end users use will be build on OPERATING SYSTEMS
top of platforms.
• A collection of software that manages computer
hardware resources and provides common services for
computer programs.
GENERATIONS OF COMPUTING (VTIPM)
• It is an essential component of the system software in a
1. (1945–55) Vacuum Tubes (15) computer system.
• Application programs usually require an operating
• Punch cards and machine language programming system to function.
2. (1955–65) Transistors and Batch Systems (15) • The most important program that runs on your
computer.
• Mainframes (IBM 1401,IBM 7094), FORTRAN compiler • It manages all other programs on the machine.
3. (1965–1980) ICs and Multiprogramming (20) • Every PC has to have one to run other applications or
programs.
• IBM System/360,OS/360, multiprogramming, • It’s the first thing “loaded”.
timesharing, MULTICS • In simple terms, an operating system is a manager.
• It manages all the available resources on a computer,
4. (1980–Present)Personal Computers (10)
from the CPU, to memory, to hard disk accesses.
• IBM PC, DOS, Macintosh, Windows, Linux • Major cost of general purpose computing is software.
• An operating system is a program that acts as an
5. (1990–Present)Mobile Computers (10)
intermediary between the user of a computer and
• PDAs, SymbianOS, Blackberry OS, Smartphones, iOS, computer hardware.
Android • Operating systems simplify and manage the complexity
of running application programs efficiently.
• Operating systems turn the ugly hardware details into
TRANSISTORS AND BATCH SYSTEMS beautiful abstractions for the use of other software.

i. Programmers bring Cards to a Card Reader.


ii. Card Reader reads (converts the commands) batch of The Operating System as a Resource Manager
jobs onto Tape.
• Allow multiple programs to run at the same time
iii. Operator carries Input Tape to the Main Processor.
iv. Main Processor does computing.

© claiming uno for ebriwan – misyel


• Manage and protect memory, I/O devices, and other
resources III. MULTIPROCESSOR OPERATING SYSTEMS
 The increasingly common way to get major
• Includes multiplexing (sharing) resources in two
computing power is to connect multiple CPUs into a
different ways:
single system
 In time  The Increasingly common way to get major-league
 In space computing power is to connect multiple CPUs into a
single system
 Even conventional desktop and notebook operating
Operating System Concepts systems are starting to deal with at least small-scale
multiprocessors and the number of cores is likely to
o Processes grow over time.
o Address spaces (Memory)  Examples: Windows and Linux, run on
o Files multiprocessors
o Input/Output
o Protection IV. PERSONAL COMPUTER OPERATING SYSTEMS –
o The shell made for single users

Development in computing over time


V. HANDHELD OPERATING SYSTEMS
o Large memories  Smaller and smaller systems, tablets, smartphones,
o Protection hardware and other handheld computers
o Disks  PDA(Personal Digital Assistant)
o Virtual memory  A small computer that can be held in a hand during
operation
 Runs mostly on UNIX based systems
DIFFERENCE OF MEMORY AND STORAGE:
VI. EMBEDDED OPERATING SYSTEMS
MEMORY – high speed, but limited; it can only store  Embedded systems run on computers that control
what is needed in the immediate time devices that are not generally thought of as
STORAGE – low speed, but larger size/space; permanent computers and which do not accept user-installed
software.
 Microwave ovens, TV sets, cars, DVD recorders,
traditional phones, and MP3 players
BUS – transportation of data from one component/site
to another  The main property which distinguishes embedded
systems from handhelds is the certainty that no
untrusted software will ever run on them.
 All software is in ROM
TYPES OF OPERATING SYSTEMS (mainframe mobile
handheld embedded smart card)
VII. SENSOR NODE OPERATING SYSTEMS
I. MAINFRAME OPERATING SYSTEMS - heavily oriented  Sensor networks are used to protect the perimeters
toward processing many jobs at once, most of which of buildings, guard national borders, detect fires in
needs a prodigious amount of I/O forests, measure temperature and precipitation for
Services Provided: weather forecasting, glean information about enemy
 The BATCH SYSTEM is one that processes routine movements on battlefields, and much more
jobs without any interactive user present.  Sensors are small battery-powered computers with
 TRANSACTION-PROCESSING SYSTEMS handle built-in radios
large numbers of small requests, for example,  Runs a small, but real operating system, usually one
check processing at a bank or airline reservations; that is event-driven, responding to external events or
Each unit of work is small, but the system must making measurements periodically based on an
handle hundreds or thousands per second internal clock
 TIMESHARING SYSTEMS allow multiple remote o Nodes have little RAM and battery lifetime is a
users to run jobs on the computer at once, such major issue
as querying a big database. o Example: TinyOS

II. SERVER OPERATING SYSTEMS VIII. REAL-TIME OPERATING SYSTEMS – In an RTOS,


 Run-on servers (either large personal computers, repeated tasks are performed within a tight time
workstations or even mainframes) boundary, while in a general-purpose operating
 Serve multiple users at once over a network and system, this is not necessarily so.
allow the users to share hardware and software
resources IX. SMART CARD OPERATING SYSTEMS
 Services: print service, file service, or web service
 Examples: Solaris, FreeBSD, Linux, and Windows  Smallest operating systems run on smart cards, which
Server 201x. are credit-card-sized devices containing a CPU chip

© claiming uno for ebriwan – misyel


 Some are powered by contacts in the reader into • Client level: 90% run Microsoft Windows(XP, 2000, CE,
which they are inserted, but contactless smart cards etc.); Mobile/multitouch (Android, iOS); Cloud computing
are inductively powered, which greatly limits what (Google’s Chrome OS)
they can do
 ROM on the smart card holds an interpreter to
interpret a programming language 3. ENTERPRISE SOFTWARE APPLICATIONS – used by big
companies; an example is when students enroll in a
portal
EVOLUTION OF IT INFRASTRUCTURE (58-65-81)
• Enterprise application providers: SAP and Oracle
General-purpose mainframe and minicomputer era:
1959 to present • Middleware providers: BEA
• 1958: first mainframes introduced

• 1965: less expensive DEC minicomputers introduced 4. DATA MANAGEMENT AND STORAGE – hard drives,
flash drives, compact disks, etc.
Personal computer era: 1981 to present
• Database software: IBM (DB2),Oracle, Microsoft (SQL
• 1981: Introduction of IBM PC
Server), Sybase (Adaptive Server Enterprise), MySQL
• Proliferation in 80s, 90s resulted in growth of personal
• Physical data storage: EMC Corp (large-scale systems),
software
Seagate, Maxtor, Western Digital
Client/server era: 1983 to present
• STORAGE AREA NETWORKS(SANS): Connect multiple
• Desktop clients networked to servers, with processing storage devices on dedicated network
work split between clients and servers

• Network may be two-tiered or multi-tiered(N-tiered)


5. NETWORKING PLATFORMS – router, landlines
• Various types of servers (network, application, Web)
• Telecommunication services -
Enterprise Computing Era: 1992 to present Telecommunications/cable company charges for voice
lines and Internet access; AT&T, Verizon
• Move toward integrating disparate networks,
applications using Internet standards and enterprise • Network operating systems: Windows Server, Linux,
applications Unix

Cloud and Mobile Computing: 2000 to present • Network hardware providers: Cisco, Alcatel-
Lucent,Nortel, Juniper Networks
• CLOUD COMPUTING: computing power and software
applications supplied over the Internet or other network
6. INTERNET PLATFORMS – search engines

INFRASTRACTURE COMPONENTS (COEDNIC) • Hardware, software, management services to support


company web sites, (including web-hosting services)
• IT Infrastructure has seven main components:
intranets, extranets
1. COMPUTER HARDWARE PLATFORMS – personal
• Internet hardware server market: IBM, Dell, Oracle, HP
computers, servers
• Internet services: Amazon, Google
• Client machines: Desktop PCs, mobile devices, laptops
• Web development tools/suites: Microsoft (.NET) Oracle
• Servers: BLADE SERVERS: ultrathin computers stored in
(Java), Adobe
racks

• Mainframes: IBM mainframe equivalent to thousands


of blade servers 7. CONSULTING SYSTEM INTEGRATION SERVICES –
Accenture, IBM Global Services
• Top chip producers: Intel, AMD, ARM, IBM
• Even large firms do not have resources for full range of
• Top firms: IBM, HP, Dell, Lenovo
support for new, complex infrastructure

• Software integration: ensuring new infrastructure


2. OPERATING SYSTEM PLATFORMS – Batch OS, Real- works with legacy systems
Time OS, Smart Card OS, etc.
• Legacy systems: older TPS created for mainframes that
Operating Systems would be too costly to replace or redesign

• Server level: 65%run Unix or Linux; 35%run Windows • Accenture, IBM Global Services, EDS, Infosys, Wipro

CHAPTER 2: PROCESSES
© claiming uno for ebriwan – misyel
PROCESSES Another instances:

 A process is an abstraction of a running program  If a peripheral device is inserted (e.g. USB) while a
 It enables doing several things at the same time process is ongoing, another process will be
 support the ability to have (pseudo) concurrent created
operation  Simply booting up the PC
 Example: Consider a User PC
•In all these cases, a new process is created by having an
• In a MULTIPROGRAMMING system, the CPU switches existing process execute a PROCESS CREATION system
from process to process quickly, running each for tens or call.
hundreds of milliseconds

PROCESS TERMINATION
DIFFERENCES:
Events which cause process termination:
• A PROCESS is an activity of some kind; simply a running
1. Normal exit (voluntary).
program
2. Error exit(voluntary).
• A PROGRAM is something that may be stored on disk, 3. Fatal error (involuntary).
not doing anything; set of instructions 4. Killed by another process(involuntary).

Example: baking vs. recipe Another instances:

MULTIPROGRAMMING - allows our CPU to work than  User uses a task manager
one or multiple processes at a time, but not  Plug out the PC
simultaneously (runs in parallel); one CPU or single
processor, multiple process in a parallel manner
PROCESS STATES
MULTIPROCESSING - multiple processors that can run
multiple processes at the same time Three states a process may be in:

1. RUNNING – actually using the CPU at that instant;


currently run by the CPU
THE PROCESS MODEL
 Can transition to ready state (pag may bagong
a. Multiprogramming four programs.
dating = interrupts the process) or
b. Conceptual model of four independent,
 blocked (waiting for input)
sequential processes.
c. Only one program is active at once. 2. READY – runnable; temporarily stopped to let another
process run
• All the runnable software on the computer, sometimes
including the operating system, is organized into a 3. BLOCKED – unable to run until some external event
number of sequential processes happens; waiting or input or waiting list
• To understand the system, it is much easier to think  blocked to ready = pag may available na input)
about a collection of processes running in (pseudo)
SCHEDULER – nakatask sa tatlong state, magdedecide
parallel
alin sa tatlo yung process
• This rapid switching back and forth is called
INTERRUPT – change in the status mode = change in the
MULTIPROGRAMMING
schedule
OPERATING SYSTEMS are designed to handle processes.
NO MORE MEMORY/RAM – not responding na ang
In multiprogramming, it brings an illusion na sabay sabay process state kaya suspended na
where in fact one at a time pa rin; an instance is while
waiting for the first system kasi matagal, instead na mag
idle, magmumumove on siya sa next system then kung IMPLEMENTATION OF PROCESSES
may ibang dinedemand ulit, next system ulit, giving the
illusion na sabay sabay niya nahahandle (kumbaga • The lowest layer of a process-STRUCTURED
mabilis lang siya mag-thank you next) OPERATING SYSTEM handles interrupts and scheduling.

• Above that layer are sequential processes.

PROCESS CREATION

Events which cause processes creation: PROCESS TABLE

1. System initialization.  One entry per process


2. Execution of a process creation system call by a  Contains important information about the
running process. process’ state
3. A user request to create a new process.
4. Initiation of a batch job.
© claiming uno for ebriwan – misyel
 Information that must be saved when the
process is switched from running to ready or
The Classical Thread Model
blocked state so that it can be restarted later
MULTITHREADING is the situation of allowing multiple
threads in the same process
Interrupt Handling and Scheduling
 One process, multiple threads inside; multiple
• Skeleton of what the lowest level of the operating parts ng program ang mapaprocess at the same
system does when an interrupt occurs. time; mas mabilis ang communication; mas may
advantage sa speed; instance variable; consumes
1. Hardware stacks program counter, etc.
less memory
2. Hardware loads new program counter from
 Pag single thread lang, intayan before magjump
interrupt vector.
to another activity which is matagal; global
3. Assembly language procedure saves registers.
variable
4. Assembly language procedure sets up new stack.
5. C interrupt service runs (typically reads and
buffers input).
ADVANTAGES OF THREAD OVER PROCESS
6. Scheduler decides which process is to run next.
7. C procedure returns to the assembly code. 1. Responsiveness:
8. Assembly language procedure starts up new  If the process is divided into multiple threads, one
current process. thread can complete its execution and its output can
be immediately returned.
2. Faster context switch:
MODELLING MULTIPROGRAMMING  Context switch time between threads is lower
compared to process context switch. Process context
• CPU utilization as a function of the number of processes
switching needs more CPU overhead.
in memory.
3. Effective utilization of multiprocessor system:
 If we have multiple threads in a single process, then
we can schedule multiple threads on multiple
processor.
4. Resource sharing:
 Resources like code, data, and files can be shared
among all threads within a process. (Stack and
registers can’t be shared)
5. Communication:
 Communication between multiple threads is easier,
as the threads shares common address space. while
in process we have to follow some specific
communication technique for communication
IDLE - downtime of CPU between two process.
6. Enhanced throughput of the system:
 If a process is divided into multiple threads, and each
THREADS thread function is considered as one job, then the
number of jobs completed per unit of time is
 In many applications, multiple activities are going on
increased, thus increasing the throughput of the
at once
system.
 Threads give the ability for the parallel entities to
share an address space and all of its data
 not possible with multiple processes (with their
INTER-PROCESS COMMUNICATION (IPC)
separate address spaces)
 Threads are lighter weight than processes, so they Processes frequently need to communicate with other
are easier (i.e.,faster) to create and destroy processes:
 Threads allow computing and IO activities to overlap
 nakapaloob sa processes na ginagawa ng isang  To pass information from process to another
processor; bawat isang thread, isang trabaho;  To enable proper sequencing when dependencies
tatlong process = tatlong threads are present
 To ensure that no two processes are ever in their
critical regions at the same time.
Thread Usage - A Word Processor Mechanisms for IPC:
 First thread interacts with the user.  Atomic read/write
 Second thread handles reformatting in the  Locks
background.  Semaphores
 Third thread handles the disk backups.  Monitors

© claiming uno for ebriwan – misyel


 Message Passing How is work scheduled in the CPU?

• Process states, process queues, context switches

RACE CONDITIONS – Two or more processes are reading Execution states of a process: Running, ready, waiting
or writing some shared data and the final result depends
How does a process move from one state to another?
on who runs precisely when; two process communicate
with each other • Scheduling, I/O, creation, termination
Example: two processes want to access the printer How are processes created?
spooler directory at the same time
• Create Process (Windows), fork/exec (Unix)
Conditions Required to Avoid Race Condition

1. No two processes may be simultaneously inside their


critical regions. – Mutual Exclusion (mutex) Threads Summary

2. No assumptions may be made about speeds or the  The OPERATING SYSTEM as a large multithreaded
number of CPUs. – No Assumption program
 Each process executes as a thread within the OS
3. No process running outside its critical region may block  Multithreading is very useful for applications
other processes. – Progress  Efficient multithreading requires fast primitives
 Processes are too heavyweight
4. No process should have to wait forever to enter its
 Solution is to separate threads from processes
critical region. – No Starvation
 Kernel-level threads much better, but still
significant overhead
 User-level threads even better, but not well
Mutual Exclusion using Critical Regions
integrated with OS
• CRITICAL REGION – the part of the program where
shared variables are accessed
CHAPTER 3: SCHEDULING

PROCESS BEHAVIOUR
Mutual Exclusion with Busy Waiting
a) CPU-bound processes spend most of their time
DISABLING INTERRUPTS
computing
 Each process disables all interrupts just after entering b) I/O bound processes spend most of their time
its critical region and re-enable them just before waiting for I/O
leaving it
 In a multicore (i.e., multiprocessor system) disabling
the interrupts of one CPU does not prevent other MULTIPROGRAMMING
CPUs from interfering with operations the first CPU is
• Overlapping I/O and CPU activities
performing
o To increase CPU utilization and job
LOCK VARIABLES
throughput
 A single, shared (lock) variable, process sets it to 1
• Previously covered the mechanisms of
and enters the critical region. If the lock is already 1,
the process just waits until it becomes 0. o Context switching
 Has the same fatal flaw that we saw in the spooler o Process queues and process states
directory.
• which process(thread) to run, for how long, etc. –
STRICT ALTERNATION SCHEDULING
 two processes strictly alternate in entering their
critical regions
 it is not really a serious candidate as a solution SCHEDULING
because it violates condition 3  Choosing which process to run next, when two or
PETERSON’S SOLUTION more of them are simultaneously in the ready state
 Deciding which process should occupy the resource
THE TSL INSTRUCTION (CPU, disk, etc.)
 Done by scheduler using the scheduling algorithm
 Many of the same issues that apply to process
Process Summary scheduling also apply to thread scheduling, although
some are different.
PROCESSES – units of execution
 JOBS - schedulable entities (processes, threads)
PROCESS CONTROL BLOCKS (PCBs) – how those units of
execution represented

© claiming uno for ebriwan – misyel


WHEN TO SCHEDULE? PREEMPTIVE SCHEDULING – The running process can be
interrupted and must release the CPU
 when a job exits
 when a job blocks on I/O
 when time slice expired
SCHEDULING ALGORITHM GOALS
o a hardware clock provides periodic interrupts
 when a new job is created All Systems
o whether to run the parent or the child
 FAIRNESS - giving each process a fair share of the
 when an I/O interrupt occurs
CPU
o from an I/O device that has now completed
 POLICY ENFORCEMENT - seeing that stated policy is
its work for a waiting job
carried out
 BALANCE - keeping all parts of the system busy
PERFORMANCE CRITERIA Batch Systems
 THROUGHPUT – number of jobs completed in unit  THROUGHPUT - maximize jobs per hour
time  TURNAROUND TIME - minimize time between
 TURNAROUND TIME (elapse time) – Amount of time submission and termination
to execute a particular process from the time it  CPU UTILIZATION - keep the CPU busy all the time
entered
 WAITING TIME – Amount of time process has been Interactive Systems
waiting in ready queue  RESPONSE TIME - respond to requests quickly
 MEETING DEADLINES – Avoid bad consequences  PROPORTIONALITY - meet users' expectations

Real-time Systems
SCHEDULING OBJECTIVES  MEETING DEADLINES - avoid losing data
 Fair - Everyone is happy  PREDICTABILITY - avoid quality degradation in
 Priority - Some are more important multimedia systems
 Efficiency - Make best use of equipment
 Encourage good behavior - Good boy/girl
 Support heavy load - Degrade gracefully SCHEDULING ALGORITHMS
 Adapt to different environment - Interactive,
BATCH SYSTEMS:
real-time, multi-media
a) FIRST-COME, FIRST-SERVED (FCFS)
 “Real-world” scheduling of people in lines (e.g.,
CATEGORIES OF SCHEDULING ALGORITHMS supermarket)
 A single queue of ready jobs
1. BATCH
 Jobs are scheduled in order of arrival to ready queue
 Periodic tasks – payroll, bills, interest calculation  Typically non-preemptive (no context switching at
(at banks) market)
 No users impatiently waiting  Jobs treated equally, no starvation.
 Possible to run for long time periods for each  When the running process blocks, the first process
process without switching on the queue is run next.
 When a blocked process becomes ready, like a newly
2. INTERACTIVE arrived job, it is put on the end of the queue, behind
 For environments with interactive users – all waiting processes.
personal computing, servers Problems
 One process cannot be hogging the CPU and
denying service to the others  Average waiting time can be large
 If small jobs wait behind long ones (high
3. REAL-TIME turnaround time)
 Only programs that are intended to further the  Non-preemptive
application at hand
 Processes may not run for long and usually do
their work and block quickly, so it’s okay to let b) SHORT JOB FIRST(SJF)
them finish  Choose the job with the smallest expected duration
first
o Person with smallest number of items to buy
Preemptive Vs. Non-preemptive  Requirement: the job duration needs to be known in
advance
NON-PREEMPTIVE SCHEDULING – The running process  Used in Batch Systems
keeps the CPU until it voluntarily gives up the CPU  Optimal for Average Waiting Time if all jobs are
available simultaneously
© claiming uno for ebriwan – misyel
Problems Various algorithms to meet these goals: FCFS/FIFO,SJF,
RR, Priority
 STARVATION – a job is waiting forever
 All jobs must be available at start – Suited for MULTIPLE-LEVEL FEEDBACK QUEUES - can combine
batch systems algorithms

INTERACTIVE SYSTEMS: CHAPTER 4: FILE SYSTEMS

a) ROUND-ROBIN SCHEDULING NEED FOR LONG-TERM STORAGE


 One of the oldest, simplest, most commonly used
Computer applications need to store and retrieve
scheduling algorithm
information. There is need for long-term storage,
 Select process/thread from ready queue in a round-
because:
robin fashion (take turns)
 Limited amount of space in main memory or
Problems
virtual memory
 Time slice too large  Information must be retained beyond the life of
o FIFO behavior a process
o Poor response to short interactive  Multiple processes may need to access (parts of)
requests same information
 Time slice too small
o Too many context switches (overheads)
o Inefficient CPU utilization Requirements for long-term information storage:
 A quantum around 20–50 msec is often a
 It must be possible to store a very large amount
reasonable compromise.
of information.
 The information must survive the termination of
the process using it.
b) PRIORITY SCHEDULING
 Multiple processes must be able to access the
 Not all processes are equally important
information at once.
 Need to consider external factors
 Email checking less priority than displaying video
WHY FILE SYSTEMS?

c) MULTI-QUEUE & MULTI-LEVEL FEEDBACK Think of a DISK as a linear sequence of fixed-size blocks
 Scheduling algorithms can be combined and supporting two operations:
o Have multiple queues
 Read block k
o Use a different algorithm among queues
 Write block k
o Move processes among queues
 Multiple queues representing different job types For large systems, few of the questions that quickly arise:
o Interactive, CPU-bound, batch, etc.
 How do you find information?
o Queues have priorities
 How do you keep one user from reading another
o Jobs can move among queues based upon
user’s data?
execution history  How do you know which blocks are free?

REAL-TIME SYSTEMS: FILE SYSTEMS


a) EARLIEST DEADLINE FIRST SCHEDULING
 FILES are logical units of information created by
 Each job has an arrival time and a deadline to finish processes.
(e.g. assignments, exams)
 Processes can read existing files and create new ones
 Always pick the job with the earliest deadline to run if need be.
 Files are managed by the operating system.
 The operating system dealing with files is known as
Scheduling Summary the FILE SYSTEM.
SCHEDULER is the module that gets invoked when a
context switch needs to happen
ROLES OF FILES SYSTEM
SCHEDULING ALGORITHM determines which process
runs and where processes are placed on queues  Implement an abstraction for secondary storage
(files)
Scheduling algorithms have many goals: Utilization,  Organize files logically (directories)
throughput, wait time, response time, etc.
 Protect data from unwanted access (security)

© claiming uno for ebriwan – misyel


 Permit access of data between processes, o Temporary flag - 0 for normal; 1 for delete file on
people, and machines (sharing) process exit
o Lock flags - O for unlocked; non-zero for locked
o Record length - Number of bytes in a record
FILES o Key position - Offset of the key within each
record
 A file is data with some properties
o Key length - Number of bytes in the key field
 Contents, size, owner, last read/write time,
o Creation time - Date and time the file was
protection, etc.
created
 A file can also have a type
o Time of last access - Date and time the file was
 Understood by other parts of the OS or runtime
last accessed
libraries
o Time of last change - Date and time the file was
 Executable, dll, source, object, text, etc.
last changed
 Understood by the file system
o Current size - Number of bytes in the file
 Block/character device, directory, link, etc.
o Maximum size - Number of bytes the file may
 A file’s type can be encoded in its name or contents
grow to
Windows encodes type in name
- .com, .exe, .bat, .dll, .jpg, etc.
THREE COMMON WAYS FOR STRUCTURING OF FILES
Unix encodes type in contents - Magic numbers, initial
characters 1) BYTE SEQUENCE: an unstructured sequence of bytes.
What is contained inside the file is specific to the
program that will write / read them.
FILE NAMING EXTENSIONS 2) RECORD SEQUENCE: is a sequence of fixed-length
records. This was a common model on mainframe
o file.bak - Backup file
computers.
o file.c - C source program 3) TREE: consists of a tree of records, each containing a
o file.gif - Compuserve Graphical Interchange key field in a fixed position in the record. The tree is
Format image sorted on the key field, to allow rapid searching for a
o file.hlp - Help file particular key. This is used on some large mainframe
o file.html - World Wide Web HyperText Markup computers for commercial data processing.
Language document
o file.jpg - Still picture encoded with the JPEG
standard REGULAR FILES are the ones that contain user
o file.mp3 - Music encoded in MPEG layer 3 audio information
format
o file.mpg - Movie encoded with the MPEG DIRECTORIES are system files for maintaining the file
standard system structure
o file.o - Object file (compiler output, not yet • Regular files are generally either ASCII files or binary
linked) files.
o file.pdf - Portable Document Format file
o file.ps - PostScript file • ASCII files can be displayed and printed as is, and they
o file.tex - Input for the TEX formatting program can be edited with any text editor.
o file.txt - General text file • Binary files have some internal structure known to
o file.zip - Compressed archive programs that use them.

FILE ATTRIBUTES FILE TYPES


o Protection - Who can access the file and in what • An executable binary file where the operating system
way will execute an executable binary file only if it has the
o Password - Password needed to access the file proper format
o Creator - ID of the person who created the file
• An ARCHIVE consists of a collection of library
o Owner - Current owner
procedures compiled but not linked. Each one is prefaced
o Read-only flag - O for read/write; 1 for read only
by a header telling its name, creation date, owner,
o Hidden flag - 0 for normal; 1 for do not display in
protection code, and size
listings
o System flag - O for normal files; 1 for system file
o Archive flag - O for has been backed up; 1 for
FILE ACCESS
needs to be backed up
o ASCII/binary flag - 0 for ASCII file; 1 for binary file Sequential Access
o Random access flag - 0 for sequential access only;
1 for random access
© claiming uno for ebriwan – misyel
 A process could read all the bytes or records in a A FREE MAP determines which blocks are free, allocated
file in order, starting at the beginning, but could
 Usually a bitmap, one bit per block on the disk
not skip around and read them out of order
 Also stored on disk, cached in memory for
 Used with magnetic tapes
performance
Random-access
REMAINING DISK BLOCKS used to store files (and dirs)
 Files whose bytes or records can be read in any
 There are many ways to do this
order
 Used with discs
 Essential for many applications, such as database
DISK LAYOUT STRATEGIES (CLI)
systems
FILES can span multiple disk blocks.

How do you find all of the blocks for a file?


FILE OPERATIONS
1. CONTIGUOUS ALLOCATION
The most common system calls relating to files:

 Create  Fast, simplifies directory access


 Delete  Inflexible, causes fragmentation, needs
 Open compaction
 Close 2. LINKED STRUCTURE
 Read
 Write  Each block points to the next, directory points to
 Append the first
 Seek  Good for sequential access, bad for all others
 Get Attributes 3. INDEXED STRUCTURE (indirection, hierarchy)
 Set Attributes
 Rename  An “INDEX BLOCK” contains pointers to many
other blocks
 Handles random better, still good for sequential
DIRECTORIES  May need multiple index blocks (linked together)

Directories serve two purposes:

 For users, they provide a structured way to organize UNIX I-NODES – implement an indexed structure for files
files
• Each I-NODE contains number of file block pointers
 For the file system, they provide a convenient
naming interface that allows the implementation to • Last block points to a block containing more disk-block
separate logical file organization from physical file addresses
placement on the disk
 Most file systems support multi-level directories
 Naming hierarchies (/, /usr, /usr/local/, …) SHARING FILES BETWEEN DIRECTORIES

• Links (or hard links) in source_file target_dir


DIRECTORY INTERNALS  Simply create another link from target_dir to the
i-node of source_file (the i-node is not
DIRECTORY is a list of entries; typically store files
duplicated)
• Most file systems support the notion of a current  Now two directories have links to source_file
directory
• The system call to remove a file is named “UNLINK”
• RELATIVE NAMES specified with respect to current
directory

• ABSOLUTE NAMES start from the root of directory tree

FILE SYSTEM LAYOUT

FILE SYSTEMS define a block size

 DISK SPACE is allocated in granularity of blocks

A “MASTER BLOCK” determines location of root directory

 Always at a well-known disk location


 Often replicated across disk for reliability

© claiming uno for ebriwan – misyel

You might also like