•
The Unix file system is a hierarchical structure that allows users
to store information by name. At the top of the hierarchy is
the root directory, which always has the name /. A typical Unix
file system might look like:
•
•
The location of a file in the file system is called its path. Since
the root directory is at the top of the hierarchy, all paths start
from /. Using the sample file system illustrated above, let us
determine the path for quiz1.txt:
•
All paths start from the root directory, so the path begins with /
•
We need to go to the home subdirectory, and the path
becomes /home
•
In the home directory, we go into the ian subdirectory. The path
is now /home/ian
•
In the ian directory, we go into the cpsc124 subdirectory. The
path is now /home/ian/cpsc124
•
The file quiz1.txt is in the cpsc124 directory. Appending the
filename
to
the
path,
the
path
becomes /home/ian/cpsc124/quiz1.txt
Files and Directories
There are 3 kinds of files: ordinary files (files), directory files (directories), and special files.
•Directories: Each directory contains a number of files. A directory can contain other directories, be contained in another directory, or both. A directory that contains a file is called that file's parent directory. Similarly, if directory A contains directory B, then directory A is directory B's parent directory. A directory that is contained in another directory is called a subdirectory.
UNIX System Overview
UNIX Architecture
Login Name
Shells
Files and Directories
File System
Filename
Pathname
System call error
When a system call discovers an error, it
returns -1 and stores the reason the called
failed in an external variable named "errno".
Process Related System Calls
The UNIX system provides several system
calls to
create and end program,
to send and receive software interrupts,
to allocate memory, and to do other useful jobs
for a process.
Four system calls are provided for creating
a process, ending a process, and waiting for
a process to complete.
fork() system call
To create a new process, you must use the
fork() system call.
The prototype for
the fork() system call is:
int fork()
fork() causes the UNIX system to create a
new process, called the "child process",
with a new process ID. The
contents
of the
child process are identical to the
contents
fork() system call (Cont’d)
The new process inherits several
characteristics of the old process. Among
the characteristics inherited are:
The environment.
All signal settings.
The set user ID and set group ID status.
The current working directory and the root
directory.
fork() returns zero in the child process and
exec() system calls (Cont’d)
Unlike the other system calls and
subroutines, a successful exec system call
does not return. Instead, control is given to
the executable binary file named as the
wait() system call
You can control the execution of child processes
by calling wait() in the parent.
wait() forces the parent to suspend execution
until the child is finished.
wait() returns the process ID of a child process
that finished.
If the child finishes before the parent gets
around to calling wait(), then when wait() is
wait() system call (Cont’d)
The prototype for the wait() system call is:
int wait(status)
int *status;
“status” is a pointer to an integer where
the UNIX system stores the value returned
by the child process. wait() returns the
exit() system call
The exit() system call ends a process and returns a
value to it parent.
The prototype for the exit() system call is:
void exit(status) int status;
By convention, when a process exits with a status of
Shell Interpreter
A
Shell
provides you with an interface to the Unix
system. It gathers input from you and executes programs
based on that input. When a program finishes executing,
it displays that program's output.
Shell is an environment in which we can run our
commands, programs, and shell scripts. There are
different flavors of a shell, just as there are different
flavors of operating systems. Each flavor of shell has its
own set of recognized commands and functions.
Shell Prompt
The prompt,
$
, which is called the
command prompt
, is
Shell Types
In Unix, there are two major types of shells −
Bourne shell − If you are using a Bourne-type shell,
the $ character is the default prompt.
C shell − If you are using a C-type shell, the % character is the
default prompt.
The Bourne Shell has the following subcategories − Bourne shell (sh)
Korn shell (ksh)
Bourne Again shell (bash) POSIX shell (sh)
The different C-type shells follow − C shell (csh)
Windows NT Architecture
Windows NT architecture is divided into two main
sections: user mode and kernel mode.
KERNEL MODE
Kernel mode is a highly privileged mode of operation in
which the code has direct access to all hardware and all
memory, including the address spaces of all user
processes. The part of Windows NT running in kernel
mode is called the Windows NT Executive.
USER MODE
Windows NT Architecture
The
environment subsystems
are services that
provide application programming interfaces (APIs)
that are specific to an operating system.
The three environment subsystems are the POSIX,
OS/2, and Win32 subsystems. Applications and
subsystems form a client/server relationship, in
which the applications are the clients and the
subsystems are the servers.
Integral Subsystem
The integral subsystems are services that provide
Windows NT Architecture
Programs and subsystems in user mode are limited in
terms of to what system resources they have access,
while the kernel mode has unrestricted access to the
system memory and external devices. The Windows NT
kernel is known as a MICRO
kernel
. The architecture
comprises a
simple kernel
,
hardware abstraction layer
(HAL), drivers, and a range of services (collectively
named
Executive
), which all exist in kernel mode.
The kernel sits between the Hardware Abstraction Layer
and
the
Executive
to
provide
multiprocessor
The NT Executive
The NT Executive takes care of the important tasks that are vital to the
entire system. This includes services such as object management, virtual memory management, I/O management, and process management.
The Executive has the following components
Kernel - The kernel is ultimately responsible for all actions on the system
and almost all functions on the system pass through the kernel. The kernel is responsible for scheduling all system actions, handling system interrupts and handles processor exceptions. On a multiprocessor system, a copy of the kernel actually runs on each processor. Because the kernel is involved in almost every action taken on an NT system, critical portions of the kernel are written in assembly language.
Object Manager - The Object Manager piece of the NT Executive is used
The NT Executive
Process Manager - The Process Manager is responsible for creating,
removing, and modifying the states of all processes and threads. It also provides information on the status of processes and threads to the rest of the system. When an application is started, it is created as a process, which requires a call to the Process Manager. Because every process must have at least one thread, the Process Manager is invoked again to create a thread.
Virtual Memory Manager - The Virtual Memory Manager (VMM)
provides management of the system's virtual memory pool. Virtual memory is a scheme that allows disk resources to be used instead of physical system memory
Local Procedure Call Facility - LPC is a mechanism that enables two
threads in different processes to exchange information.
Security Reference Monitor -The Security Reference Monitor (SRM)
is responsible for enforcing all security policies on the local computer.
I/O Manager - The I/O Manager is responsible for coordinating and