Question

In: Computer Science

assume a program in unix that have a multiple system calls how to show the list...

assume a program in unix that have a multiple system calls

how to show the list of system calls used in the program?

Solutions

Expert Solution

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:

  1. File structure related 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:

  • creat() system call : Prototype for creat() is:

int creat(file_name,mode)

char *file_name;

int mode;

  • open() system call: prototype for open()

#include<fcntl.h>

int open(file_name,option_flags[,mode])

char *file_name;

int option_flags,mode;

  • close() system call: prototyep is :

int close(file_descriptor)

int file_descriptor;

For input or output two system calls are there:

  • read() and write() system call: prototype is:

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.

  • lseek() system call:

long lseek(file_descriptor,offset,whence)

int file_descriptor;

long offset;

int whence;

the system call for channel duplication is:

  • dup() system call: It will duplicate an open file descriptor and returns the new file descriptor.

int dup(file_descriptor)

int file_descriptor;

for aliasing and removing :

  • link() system call:making an alias to a file name means that the file has more than one file name,but all names of the file refer to the same data.

int link (original_name,alias_name)

char *original_name,*alias_name;

  • unlink() system call : the opposite of link() system call is unlink() system call.the prototype is:

int unlink(file_name)

char *file_name;

for file status the system calls are:

  • stat()
  • fstat()

for access control system calls are:

  • access()
  • chmod()
  • chown()
  • umask()

for device control:

  • ioctl()

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:

  • exec() system calls: The UNIX system call that transform a executable binary file into process are the "exec" family of system calls.The prototypes are:

int execl(file_name,arg0[,arg1,..,argn],NULL)

char *file_name,*arg0,*arg1...,*argn;

  • fork() system call: To create a new process ,you must use the fork() sytem call.the ptototype is :

int fork()

  • 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.The prototype is :

int wait(status)

int *status; // status is a pointer to an integer where the UNIX system stores the value returned by the child proocess.

  • exit() system call: exit() system call ends a process and returns a value to it parent.The prototype is:

void exit(status)

int status;

For process control the system call available are:

  • signal() :The UNIX system provides a facility for sending and recieving software interruts called SIGNALS.signals are sent to a process when a predefinrd conditions happen.The prototype is:

# include<sys/signal,h>

int(*signal(signal_name,function))

int signal_name;

int(*function)();

  • kill() : The UNIX system sends a signal to a process when something happens ,such as typing the interrupt keyon a terminal,or attempting to execute an illegal instruction ,signals are also sent to a process with the kill() systemcall.Its prototype is :

int kill(process_id,signal_name)

int process_it,signal_name;

  • alarm() system call: Every process has an alarm clock stored in its system data segment .When the alarm goes off ,signal SIGALRM is sent to the calling process.The alarm clock remains set across an exec.The prototype is:

unsigned int alarm(seconds)

unsigned int seconds;

3) Interprocess communication: UNIX system allows processes to communicate with one another using :

  • pipe() system call :

int pipe(file_descriptors)

int file_descriptors[2];

  • Messages:related system calls are: msgget,msgsnd,msgrcv,msgctl.
  • Shared memory related system calls are : shmget,shmat,shmdt,shmctl.
  • semaphores relate system call are: semget(),semop().

These are the list of system calls used in the program.

Hope you help this....

Thankyou.....


Related Solutions

unix question please write a program and then show how to use top command that shows...
unix question please write a program and then show how to use top command that shows the zombie process, give snapshot of top command that shows the zombie process Write a very simple program that will show the possibility of having zombie processes. Write a program named zombie.c The main process will create a child. The child prints something like: “I am the child with pid ….. and my parent has ppid ….” Next, the child will sleep for 1...
Write a Python program that calls a function to sum all the numbers in a list...
Write a Python program that calls a function to sum all the numbers in a list and returns the result to the caller. The main program creates a list (with hard-coded or user input) and passes the list as an argument to the function. You may not use the built-in function, sum. The program calls a second function to multiply all the numbers in a list passed to it by main and returns the product back to the caller. List...
Draw a power system with multiple sources and show how synchronization will be completed including the...
Draw a power system with multiple sources and show how synchronization will be completed including the protection
We are interested in the implementation of a Unix/Linux system utility for the concatenation of a list of n text files.
Write in C We are interested in the implementation of a Unix/Linux system utility for the concatenation of a list of n text files. In order to do that we are going to consider the following syntax below where the concatenation of n text files are written in the output file all.txt or on the console if the output text file is not specified.       $./mycat file_1.txt file_2.txt   . . .   file_n.txt > all.txt
Draw a power system with multiple sources and show how synchronization will br completed including the...
Draw a power system with multiple sources and show how synchronization will br completed including the protection
This program must have 9 functions: •main() Controls the flow of the program (calls the other...
This program must have 9 functions: •main() Controls the flow of the program (calls the other modules) •userInput() Asks the user to enter two numbers •add() Accepts two numbers, returns the sum •subtract() Accepts two numbers, returns the difference of the first number minus the second number •multiply() Accepts two numbers, returns the product •divide() Accepts two numbers, returns the quotient of the first number divided by the second number •modulo() Accepts two numbers, returns the modulo of the first...
Let's assume that, an application program calls a High Level Language library function to display a...
Let's assume that, an application program calls a High Level Language library function to display a string with red color in the monitor. Explain the steps executing the operation (from function call to low hardware level).
How is the kill() system call different from all other system calls?
How is the kill() system call different from all other system calls?
Unix ramdom question. How do you display a list of files in your current directory, sorted...
Unix ramdom question. How do you display a list of files in your current directory, sorted by file size with the largest files at the top.
Multiple data: Briefly describes how each of the following can be used to show multiple data...
Multiple data: Briefly describes how each of the following can be used to show multiple data sets: a multiple bar graph, a multiple line chart, and a stack plot. When is the stack plot most useful?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT