Professional Documents
Culture Documents
Ans –
A) Process Management
B) Main-Memory Management
C) File Management
Ans –
A) Layered Approach
Users
File Systems
Inter-process
Communication
I/O and Device
Management
Virtual Memory
Primitive Process
Management
Hardware
Layered Architecture
B) Micro-kernels
Microkernel Architecture
The main function of the microkernel is to provide a
communication facility between the client program and the various
services that are also running in user space. Communication is provided
by message passing. For example, if the client program and service
never interact directly. Rather, they communicate indirectly by
exchanging messages with the microkernel.
C) Virtual Machine
Ans –
Ans –
A) UNIX Architecture
System Architecture
All Unix commands and file references are case sensitive: “This” is
a different filename than “this” because of the capitalization difference.
All Unix commands are lowercase and from two to nine characters long.
Many commands have options that are invoked by a hyphen followed by
one or more letters. Multiple options can often be requested by adding
multiple letters to a single hyphen. For example, ls -al combines the -a
and -l options.
B) Process Control
When you type a command at the Unix prompt, press Return , and
wait until the prompt comes back indicating the previous command is
done, then you have run a foreground process. You can only run one
foreground process at a time from one window, but Unix allows you to
run more than one process at once, some of which are in the
background.
To start a long program running (one that may take several minutes
to complete, for example) put it in the background by adding a & to the
command.
How environment variables are set, used, and handled, varies with the
shell. If you intend use Unix from the command line extensively, you will
probably wish to go to one of the advanced shells that has features such
as command-line editing, history access via the arrow keys, and tab-
completion of commands.
The UNIX system is actually more than strictly an operating system. UNIX
includes the traditional operating system components. In addition, a
standard UNIX system includes a set of libraries and a set of applications.
Figure 1.2 shows the components and layers of UNIX. Sitting above the
hardware are two components: the file system and process control. Next
is the set of libraries. On top are the applications. The user has access to
the libraries and to the applications. These two components are what
many users think of as UNIX, because together they constitute the UNIX
interface.
The part of UNIX that manages the hardware and the executing
processes is called the kernel. In managing all hardware devices, the
UNIX system views each device as a file (called a device file). This allows
the same simple method of reading and writing files to be used to access
each hardware device. The file manages read and write access to user
data and to devices, such as printers, attached to the system. It
implements security controls to protect the safety and privacy of
information. In executing processes, the UNIX system allocates resources
(including use of the CPU) and mediates accesses to the hardware.
Initially, there were only two types of file systems-the ones from AT&T
and Berkeley. Following are some file systems types:
s5
Before SVR4, this was the only file system used by System V, but
today it is offered by SVR4 by this name for backward compatibility only.
This file system uses a logical block size of 512 or 1024 bytes and a
single super block. It also can’t handle filenames longer than 14
characters.
ufs
This is how the Berkeley fast file systems is known to SVR4 and
adopted by most UNIX systems. Because the block size here can go up to
64 KB, performance of this file system is considerably better than s5. It
uses multiple super blocks with each cylinder group storing a superblock.
Unlike s5, ufs supports 255-character filenames, symbolic links and disk
quotas.
Ext2
Iso9660 or hsfs
This is the standard file system used by CD-ROMs and uses DOS-
style 8+3 filenames, Since UNIX uses longer filenames, hsfs also
provides Rock Ridge extensions to accommodate them.
msdos or pcfs
Most UNIX systems also support DOS file systems. You can create
this file system on a floppy diskette and transfer files to it for use on a
windows system. Linux and Solaris can also directly access a DOS file
system in the hard disk.
swap
This is used by SVR4 to host the boot programs and the UNIX
kernel. Users are not meant to use this file system.
proc or procfs
Fdisk
Creating Partitions
Both Linux and SCO UNIX allow a user to have multiple operating
systems on Intel Machines. It’s no wonder then that both offer the
Windows-type fdisk command to create, delete and activate partitions.
fdisk in Linux , however, operates differently from windows. The fdisk m
command shows you all its internal commands of which the following
subset should serve our purpose:
Command Action
A toggle a bootable flag N add a new partition
D delete a partition P Print partition table
L list known partition types Q Quit without saving
M print this menu W Write table to disk & exit.
Now that you have created a partition, you need to create a file
system on this partition to make it usable. mkfs is used to build a Linux
file system on a device, usually a hard disk partition. The exit code
returned by mkfs is 0 on success and 1 on failure.
OPTIONS
-t fstype: Specifies the type of file system to be built. If not speci- fied,
the default file system type (currently ext2) is used. fs-options File
system-specific options to be passed to the real file system builder.
Although not guaranteed, the following options are supported by most
file system builders.
-c: Check the device for bad blocks before building the file system.
-l filename Read the bad blocks list from filename -v Produce verbose
output.
Options:
-a: Mount all the file systems listed in /etc/fstab. Except those marked as
チ gnoauto チ h, excluded by the -t flag, or those that are already mounted.
-f: Force the mount of an unclean file system (dangerous), or forces the
revocation of write access when downgrading a file system’s mount
status from read-write to read-only.
-t fstype: Mount the given file system as the given file system type
Umount /oracle
Umount /dev/hda3
Umount/dev/dsk/c0t3d0s5
Unmounting a file system is not possible if you have a file open in it.
Further, just as you can’t remove a directory unless you are placed in a
directory above it, you can’t unmount a file system unless you are placed
above it. All forms take -f to force unmounting, and -v for verbosity. -a
and -A are used to unmount all mounted file systems, -A, however, does
not attempt to unmount the root file system.
Ans –
B) Named Pipe
A named pipe (also called a named FIFO, or just FIFO) is a pipe whose
access point is a file kept on the file system.
By opening this file for reading, a process gets access to the reading end
of the pipe.
By opening the file for writing, the process gets access to the writing end
of the pipe.
If a process opens the file for reading, it is blocked until another process
opens the file for writing. The same goes the other way around.
A named pipe may be created either via the ‘mknod’ (or its newer
replacement, ‘mkfifo’), or via the mknod() system call
mknod prog_pipe p
We could also provide a full path to where we want the named pipe
created. If we then type ‘ls -l prog_pipe’, we will see something like this:
The ‘p’ on the first column denotes this is a named pipe. Just like any
file in the system, it has access permissions, that define which users may
open the named pipe, and whether for reading, writing or both.
C) Message Queues
The second parameter contains flags that control how the system
call is to be processed. It may contain flags like IPC_CREAT or IPC_EXCL
and it also contains access permission bits.
1. the system call returns an integer identifying the created queue. Later
on we can use this key in order to access the queue for reading and
writing messages.
2. The queue created belongs to the user whose process created the
queue. Thus, since the permission bits are ‘0600′, only processes run on
behalf of this user will have access to the queue.
struct msgbuf {
long mtype; /* message type, a positive number (cannot be
zero). */
char mtext[1]; /* message body array. usually larger than
one byte. */
};
Lets create an "hello world" message:
/* first, define the message string */
char* msg_text = "hello world";
/* allocate a message with enough space for length of string and */ /* one
extra byte for the terminating null character. */
struct msgbuf* msg = (struct msgbuf*)malloc(sizeof(struct msgbuf) +
strlen(msg_text));
/* set the message type. for example – set it to ‘1′. */
msg->mtype = 1; /* finally, place the "hello world" string inside the
message. */
strcpy(msg->mtext, msg_text);
We may use the system call msgrcv() In order to read a message from a
message queue. This system call accepts the following list of
parameters:
int msgsz – size of largest message text we wish to receive. Must NOT be
larger than the amount of space we allocated for the message text in
‘msg’.
a positive integer – the first message on the queue whose type (mtype)
equals this integer (unless a certain flag is set in msgflg, see below).
a negative integer – the first message on the queue whose type is less
than or equal to the absolute value of this integer.
Lets then try to read our message from the message queue:
use msgrcv() to read the message. We agree to get any type, and thus */
/* use ‘0′ in the message type parameter, and use no flags (0). */