UNIX AND NETWORK PROGRAMMING
Unit 1 and 2
SECTION-A
UNIT-1
1. What do you mean by Operating System?
It can be defined as a software that controls the hardware resources of the computer and provides an environment under which programs can run.
2.Define Kernel
Generally the operating system software is called as Kernel, since it is relatively small and resides at the core of the environment.
3.System Call:
The interface to the Kernel layer of the software called system call. Libraries and common functions that built on the top the system call interface. But applications are free to use both.
4.What is Shell?
A Shell is a command line interpreter that reads user input and executes commands, The user input to a shell is normally from the terminal or sometimes from a file.
5. List out common Shells.
Bourne Shell
Bourne Again Shell
C Shell
Korn Shell
TENEX C Shell
6.Define Unix file system
It is a hierarchical arrangement of directories and files. Everything starts in the directory is called root whose name is a single character /.
7.Define File Descriptor
Is normally a non negative integer that the kernel uses to identify the files being accessed by a particular process. Whenever it opens an existing file or creates a new file, the kernel returns a file descriptor.
8. Define Program
A program is a executable file residing on a disk in a director. A program is read into memory and is executed by the kernel as a result of one of the six exec functions.
9.Define Process and Process ID
An executing instance of a program is called process; every process has a unique numeric identifier called the process ID. Is always a non-negative integer.
10. How the errors are handled in UNIX
In 2 ways.
1. extern int errno;
2. #define errno (*__errno_location())
11. Define signals
Signals are a technique used to notify a process that some condition has occurred.
Eg. Ignore signal
12.State the functions that are performed by the UNIX OS.
OPEN
READ
WRITE
LSEEK
CLOSE
13.Give the syntax for create and close function
(a) #include<functl.h>
int creat (const char *pathname, mode_t mode);
(b) #include <unistd.h>
int close(int files);
14.Define File Sharing?
Sharing of open files among different process, but before describing the dup function.
15. What are the functions that are used in XSI?
The extentions that are pread and pwrite are the functions that has been used in XSI.
16.State the types of Files in UNIX
1.Regular file
2Directory file
3. Block special file
4. Character special file
5. FIFO
6.SOCKET
7.Symbolic Link
17.State the Mode of Accessing files and types of files which can be accessed?
St_mode through which we can access
Directories,characters special files and so on.
18.Define UMASK
which is used to sets the file mode creation mask for the process and returns the previous value. This is one of the function that doesn’t have an error return
19.What do you mean by file truncation?
Emptying a file, which can do with the O_TRUNC flag to open, is a special case of truncation. We use ftruncate in the program when we need to empty a file after obtaining a lock on the file.
20.Define Buffering? What is the goal of it.
The goal of the buffering provided by the standard I/O library to use the minimum number of read and write calls. They can be achieved by a.Fully buffered
b.Line buffered
c.Unbuffered
UNIT – II
1.State the ways through which process can be terminated?
a.Return from main
b.Calling Exit
c.Calling _exit or _Exit
d.Return of the last thread from its start routine
e.Calling pthread_exit
f.Calling abort
g.Receipt of signal
h.Response of the last thread to a cancellation request
2.State the functions that can be used in Memory Allocation?
Malloc
Calloc
Realloc
Free
Alternative Memory Allocators are
Libmalloc
Vmalloc
3.State the rules that govern the changing of the resource limits
a. A process can change its soft limit to a value less than or equal
To its hard limit
b. A process can lower its hard limit to a value greater than or
Equal to its soft limit. This lowering of the hard limit is irreversible for normal users
c. Only a superuser process can raise a hard limit
4. What do you mean child process how it will be created by fork Function
The new process created by fork is called the child process.
#include <unistd.h>
pid_t fork(void)
which return 0 in child, process ID of child in parent, -1 on error.
5.Define Session
A session is a collection of one or more process groups. The processes in a process group are usually placed there by a shell pipeline.
6.What will happen if the signal occurs?
Disposition of the signal or action associated the signal will occur
By
Ignore the signal
Catch the signal
Default action apply
7.How will you write the signal function?
#include <signal.h>
Void (*signal (int signo, void (*fun) (int))) int);
Which returns the previous disposition of signal if OK SIG _ERR on error.
8.What is the use of kill function?
The Kill function send a signal to a process or group of processes. The raise function allows a process to send a signal to itself.
9.When the sleep function will be called?
1. The amount of wall clock time specified by seconds has elapsed
2. A signal is caught by the process and the signal handler returns
10. Define single Thread Multiple Thread?
(a)Eachh process is doing only one thing at a time is single thread
(b)designing a process to do more than one thing at a time within a single
process, with each thread handling a separate task.
11.Define Mutex
A Mutex is basically a lock that we set, any other thread that tries to set it will block until we release it.
12.State the Attributes of a Thread
detachstate
guardstate
stackaddr
stacksize
13.Define Thread safe
If a function can be safely called by a multiple threads at the same time, we say the function is thread-safe.
14.Define Thread Synchronization
When multiple threads of control share the same memory, we need to make sure that each thread sees a consistent view of its data. However, when one thread can modify a variable that other threads to ensure that they don’t use an invalid value when accessing the variable’s memory contents.
SECTION –B
UNIT-1
1.State and explain in detail about various features of UNIX?
2.What is Kernel? Differentiate C Shell with Bourne Shell?
3.What are the various utilities available in the UNIX? Explain it with eg.
4.What is Filter explain with eg
5.What are called as Wild card Characters what are the usage of these wild card
characters?
6.What do you mean by symbolic Link? Explain it with eg.
7.What are important unbuffered I\O functions ? Explain it with eg
8.Explain briefly all flag values used in open command?
9.Define the directory file write the structure of stat.
10. Explain in detail about the functions related with directories?
UNIT-1I
1.Define Processor and Processes explain the Inter Process Communication?
2.What do you mean by Command line Argument? Write about the functions available
to read a write to a line?
3.What are the various ways for a process to terminate?
4.Explain in detail about the global variable Environment?
5.Compare fork and vfork?Explain its function?
6.Describe signal and explain disposition of the Signal?
7.Explain in detail about stages of signal? And also explain what will happen if a blocked
Signal us generated more than once before the process unblocks the signal?
8.What do you mean by thread how the functions of thread are implemented in UNIX