Com 212 intro to system programming book Theory



Download 0.65 Mb.
View original pdf
Page49/72
Date13.05.2021
Size0.65 Mb.
#56617
1   ...   45   46   47   48   49   50   51   52   ...   72
com-212-introduction-to-system-programming-theory
9833 SS1 FISHERY LESSON NOTE
perform some activity.

Page | 50 System calls are expensive. While a procedure call can usually be performed in a few machine instructions, a system call requires the computer to save its state, let the operating system take control of the CPU, have the operating system perform some function, have the operating system save its state, and then have the operating system give control of the CPU back to you. Usually when an error occurs in a system or library calla special return value comes back, and a global variable "errno" is set to say what the error is. For example, suppose you try to open a file that does not exist include < stdio.h > include < errno.h > main)
{ int i
FILE ff fopen("
huangj/nonexist", riff NULL) { printf("f = null. errno = %d\n", errno); perror("f1");
}
}

Download 0.65 Mb.

Share with your friends:
1   ...   45   46   47   48   49   50   51   52   ...   72




The database is protected by copyright ©ininet.org 2024
send message

    Main page