In: Computer Science
assume a program in unix that have a multiple system calls
how to show the list of system calls used in the program?
Hi,
A system call is the programatic way in which a computer program requestes a service from the kernel of the operating system it is executed on.A system call is a way for programs to interact with the operating system.It is a request to the operating system to do something on behalf of the user's program.System call provides the service of the operating system to the user programs via Application Program Interface(API).It provides a n interface between a process and operating system to allow user-level processes to request services of the operating system.
UNIX system calls are used to manage the file system,control processes,and to provide interprocess communication.TheUNIX system interface consist of about 80 system calls.
System call error: When a system call discovers an error ,it returns -1 and stores the reason the called failed in an external variable name "errno".When a system call returns successfully ,it returns something other than -1,but it does not clear "errno" ."errno" only has meaning directly after a system call that returns an error.
Let us describe different classes of UNIX system calls:
A file strucure related system calls availabel in the UNIX system lets you create,open, and close files,read and write files,randomly access files,,alias and removes file,get informtion about file,check the accessibility of files,change protections,owner and group of files and control devices.Different system calls are :
creating a channel three system calls are availabe:
int creat(file_name,mode)
char *file_name;
int mode;
#include<fcntl.h>
int open(file_name,option_flags[,mode])
char *file_name;
int option_flags,mode;
int close(file_descriptor)
int file_descriptor;
For input or output two system calls are there:
int read(file_descriptor,buffer_pointer,transfer_size)
int file_descriptor;
char *buffer_pointer;
unsigned transfer_size;
int write(file_descriptor,buffer_pointer,transfer_size)
int file_descriptor;
char *buffer_pointer;
unsigned transfer_size;
Random access I/O is achieved by changing the value of this file pointer usinh the lseek() system call.
long lseek(file_descriptor,offset,whence)
int file_descriptor;
long offset;
int whence;
the system call for channel duplication is:
int dup(file_descriptor)
int file_descriptor;
for aliasing and removing :
int link (original_name,alias_name)
char *original_name,*alias_name;
int unlink(file_name)
char *file_name;
for file status the system calls are:
for access control system calls are:
for device control:
2.Process related system call:
The UNIX system provides several system calls to create and end program,to send and recieve software interrupts,to allocate memoryand to do other useful jobs for a process.
for process creation and termination:
int execl(file_name,arg0[,arg1,..,argn],NULL)
char *file_name,*arg0,*arg1...,*argn;
int fork()
int wait(status)
int *status; // status is a pointer to an integer where the UNIX system stores the value returned by the child proocess.
void exit(status)
int status;
For process control the system call available are:
# include<sys/signal,h>
int(*signal(signal_name,function))
int signal_name;
int(*function)();
int kill(process_id,signal_name)
int process_it,signal_name;
unsigned int alarm(seconds)
unsigned int seconds;
3) Interprocess communication: UNIX system allows processes to communicate with one another using :
int pipe(file_descriptors)
int file_descriptors[2];
These are the list of system calls used in the program.
Hope you help this....
Thankyou.....