Chapter 2

Transcription

Chapter 2
+
CMPS 105
Systems Programming
Prof. Darrell Long
E2.371
[email protected]
+
Chapter 2
2
+
Chapter 2: Unix Standardization and
Implementations
n A
history of UNIX/POSIX/Linux
n Unix
standards and why we need them
n Unix
limits and options and what they mean
+
History
n Before
Unix was accepted as a standard every hardware vendor
used their own operating system
n These
systems were proprietary
n Not
open source
n You
had to buy tools from the hardware vendors
n Code
was not portable between platforms
4
+
Enter Multics
n A
joint venture between MIT, AT&T Bell Labs, and GE to develop
a common OS
n Combined
n Virtual
n File
the best ideas from existing OS’s
memory
System
n Security
n etc...
n Multics
n The
was enormous (by 1960s standards)
OS failed because it was huge and cumbersome
n Everyone
still liked the idea, just not the implementation
5
+
Enter UNIX
n Several
n In
researchers at AT&T Bell Labs didn’t want Multics to die
1969 they began designing a new file system
n Still
a new idea at the time!
n They
added an assembler, a shell, process management, and
basic I/O
n Sounding
like UNIX yet?
6
+
Unix specs
n Unix
was designed to be small, flexible, portable, and efficient
n Designed
n C
by programmers for programmers
was developed to facilitate UNIX development
n Added
ideas: Pipes and many small utilities
n Composition
using the “Software Tools” philosophy
7
+
Versions of Unix
n AT&T
licensed the UNIX source code to Berkeley
n Researchers
at Berkeley modified it into BSD Unix
n Others
still couldn’t use it because without AT&T license because parts
of it still contained the original AT&T code
n These
researchers later rewrote the AT&T proprietary code so that it
could be distributed as open source
n SunOS/Solaris, DEC
n Minix
Ultrix, HPUX, Xenix were derived from BSD
was created for learning/teaching purposes
n Linus Torvalds
n First
creates Linux inspired by Minix
truly open-source UNIX
8
+
POSIX: Portable Operating System
Interface
n Originally
just applied to the OS interface
n Extended
n Not
to include shell and utilities
restricted to UNIX and UNIX-like systems
n There
are proprietary operating systems that satisfy POSIX standards
9
+
POSIX Standards
n Why
do we need them?
n Developers
n Code
UNIX)
modify (C, UNIX, etc...) to suit their needs
is no longer portable (driving factor behind creation of
n Other
issues: Modularity, reusability, interoperability, etc...
n Standards
n ANSI
efforts are driven by government and corporations
C, IEEE POSIX
10
+
Standard interfaces
11
+
UNIX standards: The Single UNIX
Specification
n The
Single UNIX Specification
n Superset
of the POSIX specs
n Maintained
n X/Open
System Interfaces (XSI)
n Additional
n File
by The Open Group
specs:
synchronization
n thread
stack address and size attributes
n thread
process-shared synchronization
n _XOPEN_UNIX
symbolic constant
12
+
Different Interfaces
n Many
different flavors of UNIX support different function
interfaces
n They
do not make a distinction between library functions and system
calls (Remember the difference?)
n POSIX
n Many
specifies a common set of interfaces and semantics
extensions exist
13
+
Versions of UNIX
n Three
branches of UNIX
n AT&T: System
n UC
III & system V (commercial version)
Berkeley: BSD
n AT&T
Bell Labs: UNIX Time sharing System
14
+
UNIX System V Release 4
n Designed
by AT&T’s UNIX System Laboratories
n Combines
n AT&T’s
n Sun
n UC
ideas from
SVR3.2
Microsystem’s SunOS
Berkeley’s 4.3 BSD
n Microsoft’s
Xenix system
15
+
Berkeley Software Distribution (BSD)
n Designed
n Originally
at UC Berkeley’s Computer Systems Research Group
AT&T’s proprietary source code
n 4.2BSD
released in 1983
n 4.3BSD
released in 1986
n 4.3BSD Tahoe
n 4.3BSD
n Each
n In
released in 1988
Reno released in 1990
step UCB replaced AT&T source
1989 identified all non-AT&T source and made it publicly available
n FreeBSD
is the continuation of BSD after it was released publicly
n Berkeley’s
Computer Systems Research Group stopped development
after 4.4BSD
16
+
17
Linux
n Created
by Linus Torvalds in 1991
n Inspired
by Minix, a simple operating system designed for teaching/
learning purposes
n Freely
n The
available under the GNU Public License
Internet would be much different without Linux boxes
n Most
n Most
web servers run on Linux
popular distributions:
n Debian/Ubuntu
n Fedora/Redhat
based
based
+Solaris
n Based
n 15
on AT&T’s System V Release 4
years of modification at Sun
n Arguably
the only commercially successful SVR4 descendant
n Formally
certified to be a UNIX system
18
+
19
Limits
n Portability
requires that data types be the same on different
architectures
n This
allows for the same code to work on various operating systems
n Portability
requires careful standardization of data types
n Standards
for how data types are stored, interpreted, sizes, formats,
endian, max, min, sign etc...
+
Limit examples
n Numerical
limits
n Signed/unsigned
n Min/max
values
n Pathnames
n Open
files
20
+
Limits cont.
Run time vs Compile time
n Compile
time limits – What’s the largest value of a short int?
n Headers
n Run
time limits – How many bytes in a file name?
n Run
time not associated with file or dir ⇒ sysconf
n Run
time associated with file or dir ⇒ pathconf/fpathconf
21
+
sysconf, pathconf, and fpathconf
n Return
values may be ambiguous if an error occurs
n config
output:
22
+
More limits
23
+
sysconf limit example:
Max Number of Open Files
n We
need to determine the maximum number of open files on
our system
n Need
code to be portable
n Each
system has a different max open files limit, therefore hardcoding
is not an option
n sysconf
may return indeterminate for the OPEN_MAX limit
n sysconf
may also error
n We
could guess... but here’s a better solution (next slide)
24
+
25
n Note
that sysconf may return a -1, in which case we use the
guess anyway.
+
26
Recap
n Portability
is an essential feature for computing systems today
n Standards
n History
and limits make portability possible*
of how UNIX became UNIX
n Described
the four UNIX systems used by the book
n FreeBSD
n Linux
n Mac
OS X
n Solaris
n *Even
with limits portability is still hard
n Anyone
had fun with ./configure?