Image 7.8 Example 2: Comprehensive Examples of Multiprocess Operating File

Let’s introduce the problems of the buffer block selection and the use of request through a set of cases of multiprocess operating files. The situations of the three processes are as follows. Process A is a write process in order to write characters “ABCDE” in str1[] to the file hello1.txt. The code is as follows:

void FunA();void main(){    ......    FunA();    ......}void FunA(){    char str1[] = "ABCDE";    int i;    //open the file    int fd = open("/mnt/user/user1/user2/hello1.txt", O_RDWR,0644));    for(i=0;i<1000000;i++)    {         //write the file         write(fd,str1,strlen(str1)); ...

Get The Art of Linux Kernel Design now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.