INTRODUCING UNIX the Operating System
Total Page:16
File Type:pdf, Size:1020Kb
CHAPTER 1 – INTRODUCING UNIX The Operating System A software that manages the hardware and provides the environment for programs to run Manages computer resources Schedules processes for the CPU Manages memory Schedules hardware I/O Interfaces with the hardware Acts as a control program Provides security Traps errors Decides what process run and with what resources Provides an interface to the user Provides a means for running applications Shields user from complex hardware details Makes computer efficient and convenient to use How a Program Runs on a Computer OS Allocates memory for the program and loads the program in it. It also loads the CPU registers with control information. The instructions provided in the program are executed by the CPU. The OS keeps track of the instruction that was last executed. If program needs to access hardware, OS does the job on its behalf. for example for file I/O, the OS directs the disk controller to open the file and make the disk available to the program. OS saves the state of the program if the program has to leave CPU temporarily. After the program has completed execution, the OS cleans up the memory and registers and makes them available for the next program. Multiprogramming Modern OS are multiprogramming allows multiple programs to reside in memory The OS creates a process for each program and controls switching of these processes. however, in computers with a single CPU, only one program (process) can run at one time. The multiuser feature is a direct outcome of multiprogramming. It allows the machine to serve multiple users In addition, a single user can run multiple programs, which is called multitasking UNIX Operating System Written in C not assembler. portable offers a rich set of programming tools to aid in developing, debugging, and maintaining programs. One of these program is the command’s interpreter, called the shell Interaction with UNIX system is through the shell. Knowing your Machine Unlike Windows, UNIX can used by many users concurrently A single copy installed on one machine can serve many users Users can use dumb terminals or their PC’s to access a central UNIX computer A terminal emulation facility running on a PC or workstation allows the PC to behave like a dumb terminal You can have a standalone UNIX machine. However, you are often connected to a large, more powerful computer Why? It is administered properly (backup, security, …) Has more Powerful processing and memory The System administrator On a large system serving hundreds of users, someone has to be in-charge of administering the system. Responsible for the management of the entire setup. allocating user accounts, maintain file systems, taking backups, managing disk space, and perform several other important functions. If you run some flavor of UNIX on your machine, then you are probably its administrator. History of Unix Developed in 1969 at AT&T Bell Labs by Ken Thompson and Dennis Richie In 1973, they rewrote it in C. It was unusual to write an OS in a high- level language. This made UNIX very portable. US Government prevented AT&T from selling computers so the system was distributed to academic institutions. It was improved significantly at the University of California at Berkley BSD Unix Created vi, C shell, symbolic linking, a better file system, and TCP/IP Other corporations started developing their own versions For more information, see http://www.unix- systems.org/what_is_unix/history_timeline.html Unix Variants BSD, Free BSD from Berkley Software Design SunOS and Solaris from Sun Microsystems AIX from IBM HP-UX from HP Tru64 UNIX from DEC IRIX from Silicon Graphics MAC OS X from Apple Linux and other Open Source variants POSIX and the Single UNIX Specification Absence of a single conforming standard affected the development of portable applications. AT&T created the “System V interface Definition” (SVID) to unify different flavors Later the X/Open (now the Open group), a consortium of vendors and users created X/Open Portability Guide (XPG) The Portable Operating System Interface for Computer Environment (POSIX) was developed by IEEE refers to OS in general, but was based on UNIX In 2001, IEEE and X/Open unified the two standards and called it Single UNIX Specification, version 3 Linux and GNU Linux is free and distributed under the GNU General Public License Most popular flavors: Ubuntu, Fedora, SuSE, Debian, and Mandriva Can be downloaded free Try to install a copy on your machine. The UNIX Architecture- The kernel Interacts with the machine’s hardware It is the core of the OS – always reside in memory Gets loaded into memory at boot time (startup) User’s applications communicate with the kernel via system calls in order to access the hardware Manages system memory Schedule processes Only one copy shared by all users. The UNIX Architecture- The shell The outer part of the OS (interact with users) Invoked only when the user logs in. Responsible for executing user commands One kernel – several shells For each user who is logged in User has a choice of shells. Examines the keyboard input (command) for special characters prior to communicating with the kernel The UNIX Architecture-The File and Process Files have places Processes have life Files Files are containers Files are static Directories and devices are also files Files are related to other files by being a part of single hierarchical structure called file system Process A program in execution Dynamic – resembles living organisms (born and die) Also forms hierarchy – when a process is a child of another process UNIX provides tools to control processes move them between foreground and background or kill them The UNIX Architecture-The System Calls UNIX System kernel, shell, applications – written in C Kernel offers services such as disk I/O operations Programs access these kernel services by invoking special functions called system calls C programmers can not use “write” system call on Windows system; instead Windows system use the standard library functions for everything; for example fprintf In UNIX, users have access to both write and fprintf in a C program meant to run a UNIX machine write – a system call fprintf – library function The UNIX Architecture- Summary Everything in the system is represented as a file. Work gets done by processes. Workload is shared by two separate programs (kernel and shell). Kernel uses system calls to do most of the work. All UNIX systems use the same system calls. Features of UNIX A multiuser system UNIX is a multiprogramming system These programs can be run by different users – multiuser Windows - single user system CPU, memory and hard disk; all dedicated to a single user Kernel uses the principle of time sharing A multitasking system UNIX is a multitasking system A user can edit a file, print another one, send email to a friend, and browse WWW – without leaving any of the applications Features of UNIX (cont.) Repository of Applications Kernel can not do everything for the users Host of applications shipped with UNIX system New tools are being added The Building block A complex task can be broken into finite number of simple ones shell offers a mechanism called the pipe that allows the output of one command to server as input to another That is why “who” output does not include a header; in case you needed to count the number of users by supplying the output to a word counting program Explains why most commands are NOT interactive Features of UNIX (cont.) Pattern Matching UNIX features many sophisticated pattern matching features For example, all C programs have the .c extension, and to use the tar command, we can just use a pattern *.c to back them to tape * - referred to as a metacharacter printf.*name – a regular expression to match all lines containing both printf and name Programming Facility The UNIX shell is also a programming language it has control structures and variables These features are used to design shell scripts programs that run UNIX commands in a batch Documentation UNIX documentation is no longer a sore point The online help facility – man commands A vast ocean of UNIX resources is available on the Internet Why Unix and not Windows? Unix is a very powerful multi-tasking OS capable of using the power of modern computers. Unix was built as a multi-user OS from the ground up and includes strong user security and control. Unix has numerous variants and is portable across systems. Unix is a powerful programming environment. It was written in C and includes a great deal of support. Also, most Unix shells are programmable. TCP/IP was implemented in BSD Unix well before MS-DOS even existed. Thus, Unix has excellent networking support. The File System is very powerful. It does not type files and has tons of utilities for working with them. Why not to use Unix? Many programs such as MS Word that are commonly used are not available in Unix. (update: some are available now such as OpenOffice). Unix uses terse text based commands with lots of options. For example, ls has 24 options. Unix is unforgiving. It gives you a lot of power, but if you delete a file or mess up settings, it can be hard to fix. Logging In The good old dumb terminal connected to the serial port was the way to connect to UNIX. Later Terminal programs became popular. For security reasons, SSH could be the only means of connecting to the remote UNIX box. UNIX users may use Putty or any of the free SSH programs available on the Net. Remote Access (Via Windows) Each students has an account on the Linux server in the Lab.