Question

In: Computer Science

For each of the following Unix system calls, give a condition that causes it to fail:...

For each of the following Unix system calls, give a condition that causes it to fail: open, read, fork, execve, unlink.

Solutions

Expert Solution

open():

The open() system call will when the required file(resource) is not present in specified Directory path

read():

1)when the seek pointer(file offset) is at the end of the file, since there are no words(bytes) to read the read()   will fails and it returns 0.

2)When there are no bytes to read in a file i.e., byte count=0 , then the read() will fail

fork():

fork() mainly fails when there is no freespace memory left. i.e., the kernel is not able to copy the parent process page tables to the child process. we can know that the fork is failed whenever fork() returns -1.

fork() returns -1, whenever the bit 'errno' inside the fork() is SET.

execve():

execve() fails and returns to the calling process whenever:

The number of bytes(words) in a newly created process's argument list is bigger than the limit imposed by OS

unlink():

unlink() is used to delete the file names.

when the filename we want to unlink does not exist in the specified path then the unlink() system call fails.

On success unlink() returns "0" , on failure it returns "-1"

These are some of the conditions where the above mentioned system calls fail

***please give a like if you are satisfied with the answer. if you have any doubts or you need any further information ask me through comments. THANK YOU! ***

 

Related Solutions

List TWO CAUSES of EACH clinical condition. Explain why it causes this clinical condition.
List TWO CAUSES of EACH clinical condition. Explain why it causes this clinical condition.- HYPOTHYROIDISM1.2.- HYPERTHYROIDISM1.2.
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?
Give a briefly explanation of each of the following five main causes of pollution :
  Give a briefly explanation of each of the following five main causes of pollution : - Exhaust and emissions from vehicles and industries. -Dumping waste in water bodies. - Accumulation of non-biodegradable waste (like plastic). - Excessive use of chemicals (herbicides and pesticides) in agriculture. - Deforestation and overgrazing.  
Give four reasons why system calls are typically implemented using interrupts instead of function calls.
Give four reasons why system calls are typically implemented using interrupts instead of function calls.
1.Give a briefly explanation of each of th following five main causes of pollution : -...
1.Give a briefly explanation of each of th following five main causes of pollution : - Exhaust and emissions from vehicles and industries. -Dumping waste in water bodies. - Accumulation of non-biodegradable waste (like plastic). - Excessive use of chemicals (herbicides and pesticides) in agriculture. - Deforestation and overgrazing. 2. Give a briefly explanation of the each of the Five main consequences of pollution : - Respiratory disease and other health problems in humans. - Death of aquatic Organisms due...
What are System calls. Provide 6 file and directory system calls
What are System calls. Provide 6 file and directory system calls
What are VT features with UNIX and give examples.
What are VT features with UNIX and give examples.
Describe the condition and causes of cholelithiasis. What are three possible treatments for this condition? How...
Describe the condition and causes of cholelithiasis. What are three possible treatments for this condition? How would a patient's diet affect this condition? please 230- 250 word discussion no plagiarism please use medical terminology
Modify the bellow program by using only system calls to perform the task. These system calls...
Modify the bellow program by using only system calls to perform the task. These system calls are open,read,write, and exit .Use text and binary files to test your programs. #include <stdio.h> void main(int argc,char **argv) { FILE *fp1, *fp2; char ch, buf[20], *pos; int n; pos = buf; if ((fp1 = fopen(argv[1],"r")) == NULL) { puts("File cannot be opened"); exit(1); } fp2 = fopen(argv[2], "w"); while ((n = fread(pos, sizeof(char), 20, fp1)) == 20) { fwrite(pos, sizeof(char), 20, fp2); }...
Why markets fail and what are the causes of market failure in the past present and...
Why markets fail and what are the causes of market failure in the past present and foreseeable future. - Remember externalities, public good, imperfect markets, information asymmetry etc are among the factors to consider
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT