unix system overview - kennesaw state university

22
UNIX System Overview

Upload: others

Post on 16-Oct-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: UNIX System Overview - Kennesaw State University

UNIX System Overview

Page 2: UNIX System Overview - Kennesaw State University

UNIX Architecture

● Kernel of os– Software that controls hardware resources

& provides environment under which programs can run

● System calls - Interface to kernel● Libraries of common functions – built on

top of system calls● Shell – interface for running other

programs

Page 3: UNIX System Overview - Kennesaw State University

UNIX Architecture

Page 4: UNIX System Overview - Kennesaw State University

Logging In

● Login name– Password file – usually in /etc/passwd

– 7 colon separated fields● Login name● Encrypted password● Numeric user id● Numeric group id● Comment field● Home directory● Shell program

Page 5: UNIX System Overview - Kennesaw State University

Shells

● Command line interpreter – reads user input & executes commands

– Bourne shell – written by Steve Bourne

– C shell – written by Bill Joy

– Korn shell – written by David Korn

– Bourne-again shell (bash) – GNU shell

Page 6: UNIX System Overview - Kennesaw State University

File System

● Hierarchical arrangement of files & directories

● Starts at root – symbolic name is /● Directory – file that contains directory

entries– Directory entry – filename & file attribute

● Size, owner, permissions, date last modified, ...

Page 7: UNIX System Overview - Kennesaw State University

File Names

● Slash (/) & null characters – cannot appear in a file name

● . (current directory) & .. (parent directory) are automatically created

Page 8: UNIX System Overview - Kennesaw State University

Pathname

● Sequence of 1 or more filenames separated by /'s & potentially starting with a /

● Start with / - absolute pathname● Otherwise – relative pathname

Page 9: UNIX System Overview - Kennesaw State University

Directories

● Working directory– Current directory

● Home directory– Each user has home directory –

subdirectory of home

Page 10: UNIX System Overview - Kennesaw State University

Input & Output

● File descriptor – non-negative integer used by kernel

● Predefined descriptors – automatically opened whenever new program is run

– Standard input

– Standard output

– Standard error

Page 11: UNIX System Overview - Kennesaw State University

Input & Output

● Unbuffered I/O– Provided by functions open, read, write,

lseek, close

● Standard I/O– Buffered interface to unbuffered functions

– printf

– fgets

Page 12: UNIX System Overview - Kennesaw State University

Programs & Processes

● Program – executable file on disk– Read into memory & executed by kernel

● Process – executing instance of a program– Process id – unique numeric identifier

● Process control– Fork

– Exec

– waitpid

Page 13: UNIX System Overview - Kennesaw State University

Threads

● Threads within a process share address space

● Have own stack● Need to synchronize access to shared

variables● Each thread – own id

Page 14: UNIX System Overview - Kennesaw State University

Error Handling

● System functions – usually return a numeric error flag - <error.h>

● Each thread needs its own copy of errno● Errno – not reinitialized each time – only

use if an error has occurred● Never set to 0● strerror – returns pointer to error message● perror – creates error message on

standard error

Page 15: UNIX System Overview - Kennesaw State University

Error Recovery

● 2 types of errors: fatal & nonfatal● Fatal error – no recovery possible● Nonfatal – delay & try later

Page 16: UNIX System Overview - Kennesaw State University

User Identification

● User ID - numeric value – assigned by system administrator when account is created

● root – id 0● Group id – assigned by system

administrator● Groups – collection of users with common

characteristics– Sharing of resources within group

Page 17: UNIX System Overview - Kennesaw State University

Signals

● Technique to notify a process that a condition has occurred

● Choices for dealing with signal– Ignore

– Let default action occur

– Provide a function which is called

Page 18: UNIX System Overview - Kennesaw State University

Time Values

● Calendar time – number of seconds since Epoch (Jan 1, 1970)

– time_t data type

● Process time – measures CPU resources used

– Measured in terms of clock ticks

– clock_t data type

Page 19: UNIX System Overview - Kennesaw State University

Time Values

● Execution time of a process– Wall Clock time

● Amount of time for process to run

– User CPU time● CPU time for user instructions

– System CPU time● CPU time for kernel executing instructions

for user

● time command

Page 20: UNIX System Overview - Kennesaw State University

System Calls & Library Functions

● System calls – functions to request services from kernel

● C library function with same name as system call

Page 21: UNIX System Overview - Kennesaw State University
Page 22: UNIX System Overview - Kennesaw State University