Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
23 views
AOS ch1
AOS
Uploaded by
customercare.emirus
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save AOS-ch1 For Later
Download
Save
Save AOS-ch1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
23 views
AOS ch1
AOS
Uploaded by
customercare.emirus
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save AOS-ch1 For Later
Carousel Previous
Carousel Next
Save
Save AOS-ch1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 30
Search
Fullscreen
Introduction to UNIX/LINUX Kernel GENERAL OVERVIEW OF THE SYSTEM * The UNIX system bas become quite popular since its inception in 1969 * The system is divided into two parts. > The first part consists of programs and services that have made the UNIX system environment. It is the part readily apparent to users, including such programs as the shell, mail, text processing packages, and source code control systems. » The second part consists of the operating system that supports these programs and services.Several reasons to choose UNIX system : * The system is written in a high-level language, making it easy to read, understand, change, and move to other machines. *It has a simple user interface that has the power to provide the services that users want. * It provides primitives that permit complex programs to be built from simpler programs. * It uses a hierarchical file system that allows easy maintenance and efficient implementation. * It uses a consistent format for files, the byte stream, making application programs easier to write. * It provides a simple, consistent interface to peripheral devices. * It is a multi-user, multi-process system; each user can execute several processes simultaneously. * It hides the machine architecture from the user, making it easier to write programs that run on different hardware implementations.System structure The operating system interacts directly 3 with the hardware, providing common services to programs and insulating them from hardware. Other application programs Other application programs Figure 1.1. Architecture of UNIX Systems* As there are set of layers, the system is commonly called the System Kernel or just Kernel Emphasize its isolation from user programs. * As programs are independent of the underlying hardware, it is easy to move them between UNIX systems running on different hardware. » Programs such as the shell and editors (ed and vi) shown in the outer layers interact with the kernel by invoking a well defined set of system calls. > The system calls instruct the kernel to do various operations for the calling program and exchange data between the kernel and the program. » Several programs shown in the figure are in standard system configurations and are known as commands, but private user programs may also exist in this layer as indicated by the program whose name is a.out, the standard name for executable files produced by the C compiler.* The standard C compiler, cc, is in the outermost layer of the figure: it invokes a C preprocessor, two-pass compiler, assembler, and loader (link-editor), all separate lower-I programs. * Even in figure two-level hierarchy of application programs is shown, users can extend the hierarchy to whatever levels are required.User perspective It reviews high-level features of the UNIX system such as the file system, the processing environment and building block primitives(ex. pipes). 1. The File System The UNIX file system is characterized by ¢ a hierarchical structure, * consistent treatment of file data, * the ability to create and delete files, © dynamic growth of files, * the protection of file data, * the treatment of peripheral devices (such as terminals and tape units) as files.> The file system is organized as a tree with a single root node called root (written “/"); > every non-leaf node of the file system structure is a directory of files . > files at the leaf nodes of the tree are either directories, regular files, or special device files. > The name of a file is given by a path name that describes how to locate the file in the file system hierarchy. >A path name is a sequence of component names separated by slash characters. -> a component is a sequence of characters that designates a file name that is uniquely contained in the previous (directory) component. > A full path name starts with a slash character and specifies a file that can be found by starting at the file system root and traversing the file tree, following the branches that lead to successive component names of the path name. (Ex. /usr/src/cmd/who.c ).USER PERSPECTIVE —-—-;CDRe—ae~” fs1 bin etc unix dev mjbmaury sh date who passwd src bin tty00 ttyO1 cmd date.c — who.c Figure 1.2. Sample File System Tree* Programs in the UNIX system have no knowledge of the internal format in which the kernel stores file data, treating the data as an unformatted stream of bytes. * Programs may interpret the byte stream as they wish, but the interpretation has no bearing on how the operating system stores the data. * Directories are like regular files in this respect; the system treats the data in a directory as a byte stream, but the data contains the names of the files in the directory in a predictable format so that the operating system and programs such as Is (list the names and attributes of files) can discover the files in a directory. * Permission to access a file is controlled by access permissions associated with the file. * Access permissions can be set independently to control read, write and execute permission for three classes of users : > the file owner, > a file group, > an everyone else.Suppose the name of the executable version of the program copy. A user at a terminal invokes the program by typing copy oldfile newfile Here, argc is 3, argv[O] points to the character string copy (the program name is conventionally the Oth parameter), argv[1] points to the character string oldfile, argv[2] points to the character string newfile * The program then checks that it bas been invoked with the proper number of parameters. * If so, it invokes the open system call "read-only" for the file oldfile, and if the system call succeeds, invokes the create system call to create newfile. The permission modes on the newly created file will be 0666 (octal), allowing all users access to the file for reading and writing. All system calls return —1 on failure; if the open or create calls fail, the program prints a message and calls the exit system with return status 1, terminating its execution and indicating that something went wrong.The open and create system calls return an integer called a file descriptor, which the program uses for subsequent references to the files. The write system read system eau returns the number of bytes read, returning O when it reaches the end of file.#include
char buffer[2048]; int version = 1; /* Chapter 2 explains this */ main(argc, argv) int arge; char *argv{]; { int fdold, fdnew; if (argc 3) { _ printf("need 2 arguments for copy program\n’); exit(1); } fdold = open(argv[1], O_RDONLY); /* open source file read only */ if (fdold == -1) { _ printf("cannot open file %s\n", argv[1]); exit(1); } fdnew = creat(argv[2], 0666); /* create target file rw for all */ if (fdnew —I) { _ printf("cannot create file %An", argv[2]); exit(1); } copy(fdold, fdnew); exit (0);copy(old, new) int old, new; { int count; while ((count = read(old, buffer, sizeof(buffer))) > 0) write(new, buffer, count);Processing Environment A program is an executable file, and a process is an instance of the program in Execution. Various system calls allow processes to create new processes, terminate processes, synchronize stages of process execution, and control reaction to various events. The system calls allow users to write programs that do sophisticated Operations. The kernel of the UNIX system does not contain many functions that are part of the "kernel" in other systems. The prime example of such a program is the shell, the command interpreter program that users typically execute after logging into the system. The shell interprets the first word of a command line as a command name: for many commands, the shell forks and the child process execs the command associated with the name, treating the remaining words on the command line as parameters to the command.The shell allows three types of commands 1. a command can be an executable file that contains object code produced by compilation of source code (a C program for example). 2. a command can be an executable file that contains a sequence of shell command lines 3. a command can be an internal shell command (instead of an executable file). The internal commands make the shell a programming language in addition to a command interpreter and include commands for looping (for-in-do-done and while-do-done), commands for conditional execution (if-then-else-fl), a "case" statement command, a command to change the current directory of a process (cd), and several others.The shell syntax allows for pattern matching and parameter processing. > The shell usually executes a command synchronously, waiting for the command to terminate before reading the next command line. > it also allows asynchronous execution, where it reads the next command line and executes it without waiting for the prior command to terminate. Commands executed asynchronously are said to execute in the backgroundBuilding Block Primitives : The capability to redirect I/O. UNIX system is to provide operating system primitives that enable users to write small, modular programs that can be used as building blocks to build more complex programs. * Processes conventionally have access to three files: > they read from their standard input file, > write to their standard output file, and > write error messages to their standard error file. * Processes executing at a terminal typically use the terminal for these three files, but each may be "redirected" independently. Example : the command Is => lists all files in the current directory on the standard output, Is> output => redirects the standard output to the file called "output" in the current directory, mail mjb < letter => opens the file "letter" for its standard intput and mails its contents to the user named "mjb."2. the pipe a mechanism that allows a stream of data to be passed between reader and writer processes. * Processes can redirect their standard output to a pipe to be read by other processes that have redirected their standard input to come from the pipe. * The data that the first processes write into the pipe is the input for the second processes. * The second processes could also redirect their output, and so on, depending on programming need. Example : grep main a.c b.cc.c1 we —I counts the number of lines in the files that contain the string "main"; the output from grep is "piped" directly into the wc commandAssumptions about hardware The execution of user processes on UNIX systems is divided into two levels: user and kernel. When a process executes a system call, the execution mode of the process changes from user mode to kernel mode: Processes in user mode can access their own instructions and data but not kernel instructions and data (or those of other processes). Processes in kernel mode, however, can access kernel and user addresses. Some machine instructions are privileged and result in an error when executed in user mode.> Interrupts and Exceptions The UNIX system allows devices such as I/O peripherals or the system clock, that interrupt the CPU asynchronously. On receipt of the interrupt, the kernel saves its current context, determines the cause of the interrupt, and services the interrupt. * The hardware usually prioritizes devices according to the order that interrupts should be handled. When the kernel services an interrupt, it blocks out lower priority interrupts but services higher priority interrupts. * An exception condition refers to unexpected events caused by a process, such as addressing illegal memory, executing privileged instructions, dividing by zero, and so on.> Exceptions happen "in the middle" of the execution of an instruction, and the system attempts to restart the instruction after handling the exception. > interrupts are considered to happen between the execution of two instructions, and the system continues with the next instruction after servicing the interrupt.> Processor Execution Levels The kernel must sometimes prevent the occurrence of interrupts during critical activity, which could result in corrupt data if interrupts were allowed. Computers typically have a set of privileged instructions that set the processor execution level in the processor status word. Setting the processor execution level to certain values masks off interrupts from that level and lower levels, allowing only higher- level interrupt. If the kernel masks out disk interrupts, all interrupts except for clock interrupts and machine error interrupts are prevented. If it masks out software interrupts, all other interrupts may occur.Software Interrupts Figure 1.6. Typical Interrupt Levels Higher Priority Lower Priority> Memory Management * The kernel permanently resides in main memory as does the currently executing Process. * When compiling a program, the compiler generates a set of addresses in the program that represent addresses of variables and data structures or the addresses of instructions such as functions. * The compiler generates the addresses for a virtual machine as if no other program will execute simultaneously on the physical machine.* When the program is to run on the machine, the kernel allocates space in main memory for it, but the virtual addresses generated by the compiler need not be identical to the physical addresses that they occupy in the machine. * The kernel coordinates with the machine hardware to set up a virtual to physical address translation that maps the compiler- generated addresses to the physical machine addresses. * The mapping depends on the capabilities of the machine hardware, and the parts of UNIX systems that deal with them are therefore machine dependent.Architecture of user programs the UNIX : trap operating User Level a a Kernel Level” ~~ ~~ system t + ow eae] buffer cache i character: block device drivers [ hardware controlblock diagram of the kernel, showing various modules and their relationships to each other. it shows the file subsystem on the left and the process control subsystem on the right, the two major components of the kernel. shows three levels: user, kernel, and hardware. Assembly language programs may invoke system calls directly without a system call library. Programs frequently use other libraries such as the standard I/O library to provide a more sophisticated use of the system calls.> The file subsystem accesses file data using a buffering mechanism that regulates data flow between the kernel and secondary storage devices. * The buffering mechanism interacts with block I/O device drivers to initiate data transfer to and from the kernel. Device drivers are the kernel modules that control the operations of peripheral devices. Block I/O devices are random access storage devices alternatively, their device drivers make them appear to be random access storage devices to the rest of the system. > The process control subsystem is responsible for process synchronization inter-process communication, memory management, and process scheduling. The memory management module controls the allocation of memory. If at any time the system does not have enough physical memory for all processes, the kernel moves them between main memory and secondary memory so that all processes get a fair chance to execute. Vv> The scheduler module allocates the CPU to processes. > There are several forms of inter-process communication, ranging from asynchronous signaling of events to synchronous transmission of messages between processes. > the hardware control is responsible for handling interrupts and for communicating with the machine. Devices such as disks or terminals may interrupt the CPU while a process is executing. > If so, the kernel may resume execution of the interrupted process after servicing the interrupt: Interrupts are not serviced by special processes but by special functions in the kernel, called in the context of the currently running process.
You might also like
Unit 1 Notes of Advance Operating System
PDF
100% (2)
Unit 1 Notes of Advance Operating System
18 pages
UNIX History UNIX Kernel
PDF
No ratings yet
UNIX History UNIX Kernel
8 pages
Unit - V
PDF
No ratings yet
Unit - V
30 pages
Ex No 1 - 4
PDF
100% (2)
Ex No 1 - 4
45 pages
Operating Systems and Unix
PDF
No ratings yet
Operating Systems and Unix
46 pages
Unit 1: Unix System Overview
PDF
No ratings yet
Unit 1: Unix System Overview
31 pages
System Structure
PDF
No ratings yet
System Structure
7 pages
Notes of Module 1
PDF
No ratings yet
Notes of Module 1
10 pages
Unit 1
PDF
No ratings yet
Unit 1
9 pages
UNIX System Programming
PDF
No ratings yet
UNIX System Programming
35 pages
intro-UNIX
PDF
No ratings yet
intro-UNIX
36 pages
Operating system (Unix)
PDF
No ratings yet
Operating system (Unix)
11 pages
Unix For Beginning Users
PDF
No ratings yet
Unix For Beginning Users
121 pages
Unix Unit1
PDF
No ratings yet
Unix Unit1
30 pages
unix notes.docx
PDF
No ratings yet
unix notes.docx
66 pages
What is Unix
PDF
No ratings yet
What is Unix
5 pages
Chapter 1
PDF
No ratings yet
Chapter 1
21 pages
Rtos Unit-1
PDF
No ratings yet
Rtos Unit-1
7 pages
UNIX Basics and The UNIX File System
PDF
No ratings yet
UNIX Basics and The UNIX File System
56 pages
Perl and Python Seminar
PDF
No ratings yet
Perl and Python Seminar
25 pages
Unix
PDF
No ratings yet
Unix
35 pages
CS2
PDF
No ratings yet
CS2
44 pages
UNIX Basics
PDF
0% (1)
UNIX Basics
136 pages
Introduction To UNIX
PDF
No ratings yet
Introduction To UNIX
34 pages
Network Programming Notes New Libre
PDF
No ratings yet
Network Programming Notes New Libre
30 pages
O/S Overview: FD Open ("Out", 1) Write (FD, "Hello/n", 6) Pid Fork
PDF
No ratings yet
O/S Overview: FD Open ("Out", 1) Write (FD, "Hello/n", 6) Pid Fork
5 pages
Unix
PDF
No ratings yet
Unix
35 pages
Unit 01
PDF
No ratings yet
Unit 01
10 pages
Ch1.IntroductionToUNIX 31 (1)
PDF
No ratings yet
Ch1.IntroductionToUNIX 31 (1)
31 pages
UNIX M-1,2&5 MQP SOL
PDF
No ratings yet
UNIX M-1,2&5 MQP SOL
28 pages
CH6
PDF
No ratings yet
CH6
18 pages
Unix File System
PDF
No ratings yet
Unix File System
28 pages
Unix - Introduction: Prepared by Jadala Vijaya Chandra
PDF
No ratings yet
Unix - Introduction: Prepared by Jadala Vijaya Chandra
6 pages
Ge 2155 Full
PDF
No ratings yet
Ge 2155 Full
81 pages
Unix - Session09 & 10
PDF
100% (1)
Unix - Session09 & 10
111 pages
Case Study On Unix
PDF
No ratings yet
Case Study On Unix
6 pages
Unix Progrmng
PDF
No ratings yet
Unix Progrmng
10 pages
System Programming: Chapters 1 & 2
PDF
No ratings yet
System Programming: Chapters 1 & 2
55 pages
What Is An Operating System (OS) ?: Abstract Way
PDF
No ratings yet
What Is An Operating System (OS) ?: Abstract Way
6 pages
Advanced UNIX
PDF
No ratings yet
Advanced UNIX
141 pages
LEC 3
PDF
No ratings yet
LEC 3
21 pages
1.UNIX Operating System
PDF
No ratings yet
1.UNIX Operating System
37 pages
Chapter 2 Introduction to UNIX concepts
PDF
No ratings yet
Chapter 2 Introduction to UNIX concepts
12 pages
Ge 2155 Full
PDF
No ratings yet
Ge 2155 Full
81 pages
1 Unix
PDF
No ratings yet
1 Unix
90 pages
unix-aucse.com
PDF
No ratings yet
unix-aucse.com
15 pages
Advance Operating System
PDF
No ratings yet
Advance Operating System
18 pages
OS Manual
PDF
No ratings yet
OS Manual
63 pages
Unix
PDF
No ratings yet
Unix
10 pages
Ques1. Explain UNIX System Architecture.: Ans. at The Center of The UNIX Onion Is Program
PDF
No ratings yet
Ques1. Explain UNIX System Architecture.: Ans. at The Center of The UNIX Onion Is Program
9 pages
Lec 3
PDF
No ratings yet
Lec 3
21 pages
Unix Case Study
PDF
88% (8)
Unix Case Study
5 pages
LINUX Unit - 1
PDF
No ratings yet
LINUX Unit - 1
7 pages
UNIX Concepts: 1. How Are Devices Represented in UNIX?
PDF
No ratings yet
UNIX Concepts: 1. How Are Devices Represented in UNIX?
15 pages