Unit I
Unit I
Unit I
Task Management
memory management
File Management
Process synchronization
Sun Solaries
Mac OS
Features:
1.Creation of child process—fork()
2.Termination of a process
3.Waiting for termination of a child process
Structure of Modern Unix Systems
Common Facilities
1.STREAMS
2.Blak device switch
3.Virtual memory frame work
4.Execution switch
5.Vnode Vfs interface
6.Schedular framework
Structure of Modern Unix Systems
Features of Unix
Ability to support multi user and multitasking
Portability
Excellent network environment
Adaptability and simplicity
Better security
Flexible file systems
History of Linux
the Unix operating system was conceived and implemented by
Ken Thompson and Dennis Ritchie (both of AT&T Bell Laboratories) in
1969 and first released in 1970
In 1977, the Berkeley Software Distribution (BSD) was developed by the
Computer Systems Research Group (CSRG) from UC Berkeley, based on
the 6th edition of Unix from AT&T
In 1983, Richard Stallman started the GNU project with the goal of
creating a free UNIX-like operating system. As part of this work, he wrote
the GNU General Public License (GPL). By the early 1990s, there was
almost enough available software to create a full operating system
In 1991, while studying computer science at University of Helsinki, Linus
Torvalds began a project that later became the Linux kernel. He wrote the
program specifically for the hardware he was using and independent of an
operating system because he wanted to use the functions of his new PC
with an 80386 processor
Features of Linux
User3
User1 User2
• /Bin: contains executable files for most of the unix
commands.
• /Dev: contain files that control various input & output
devices.
• /Lib: contains all the library functions in binary form.
• /Usr: contains several directories each associated with
a particular user.
• /Tmp: contain the temporary files created by unix or
by any user.
• /Etc: contains configuration files of the system.
Architecture
pattern space
P—the print first line command prints only
list command(I)
if (fd ==-1)
{
// print which type of error have in a code
printf("Error Number % d\n", errno);
Return value:
-1-------error
0-----success
Int filedes(fd)—2 properties
1.Freeup all the file desc
2.De allocate all the resources for file table entry
#include<stdio.h>
#include <fcntl.h>
int main()
{
int fd1 = open("foo.txt", O_RDONLY);
if (fd1 < 0)
{
perror("c1");
exit(1);
}
printf("opened the fd = % d\n", fd1);
fd = open("foo.txt", O_RDONLY);
if (fd < 0) { perror("r1"); exit(1); }
sz = read(fd, c, 10);
printf("called read(% d, c, 10). returned th
" %d bytes were read.\n", fd, sz);
c[sz] = '\0';
printf("Those bytes are as follows: % s\n", c
}
Write() function
• Data is written to an open file with the write function.
#include <unistd.h>
ssize_t write(int filedes, const void *buf, size_t nbytes);
Returns: number of bytes written if OK,-1 on error
• write writes nbyte no. of bytes from the generic buffer
buf to the file descriptor filedes.
Process Control
The process control provided by the unix system
and includes
1.Creation of a process
2.Process execution
3.Process termination
Every process have a unique id(always unique)
and a non negative number
Unique ID
Reused
Process ID
Prsocess ID-0 is the scheduler process it is known
as swaper (scheduling)
Process ID-1is the INIT process and it is invoked
by the kernel at end of the bootstrap procedure
Process ID-2 is the pagedaemon, responsible for
paging of the virtual memory system..
Process Identifiers
Process Control System calls
fork()
vfork()
Exit()
Exec()
Wait()
Waitpid()
fork() system call
To create a new process, you must use the fork()
system call.
#include<unistd>
Pid_t fork(void);
Return Values:
0—in child ,the process Id of child
1---Error
The process is created by fork is called child
process.
The function is called once but return Twice.
Execution .
fork() system call have no arguments
4356 7 89
Pid num glob var
For parent
4357 6 88
Pid num glob var
vfork() system call
It is like a fork() system call,
pid_tpid---
1. pid===-1 wait for only child
2.pid>0 wait for child process ID equal to pid
3.pid==0 wait for any child process GID is equal to the
signal to calling process