ContainerTracer  0.1
Functions | Variables
sync.h File Reference

Synchronization program based on pipe. More...

#include <stdio.h>
#include <unistd.h>
#include <errno.h>
Include dependency graph for sync.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static int TELL_WAIT (void)
 Pipe initialize sequence. You must call before use this source. More...
 
static int TELL_PARENT (void)
 The child calls parents. More...
 
static int WAIT_PARENT (void)
 Receive from parent's call. More...
 
static int TELL_CHILD (void)
 The parent calls children. More...
 
static int WAIT_CHILD (void)
 Receive from child's call. More...
 

Variables

static int pfd1 [2]
 
static int pfd2 [2]
 

Detailed Description

Synchronization program based on pipe.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

In Linux, the size of pipe is about 4KB. And the synchronization method is implemented by using R/W's blocking specification.

Author
BlaCkinkGJ (ss5ki.nosp@m.jun@.nosp@m.gmail.nosp@m..com)
Version
0.1
Date
2020-08-09
Note
Rochkind, M. J. (2004). Advanced UNIX programming. Pearson Education.

Function Documentation

◆ TELL_CHILD()

static int TELL_CHILD ( void  )
static

The parent calls children.

Returns
0 for success to write, -EIO for fail to write
Note
This doesn't wake up a specific child. This wakes randomly selected a child.

◆ TELL_PARENT()

static int TELL_PARENT ( void  )
static

The child calls parents.

Returns
0 for success to write, -EIO for fail to write
Note
This doesn't wake up a specific parent. This wakes randomly selected a parent.

◆ TELL_WAIT()

static int TELL_WAIT ( void  )
static

Pipe initialize sequence. You must call before use this source.

Returns
0 for success to make pipe, -EPIPE for fail to make pipe.

◆ WAIT_CHILD()

static int WAIT_CHILD ( void  )
static

Receive from child's call.

Returns
0 for success to read, -EIO for fail to read.

◆ WAIT_PARENT()

static int WAIT_PARENT ( void  )
static

Receive from parent's call.

Returns
0 for success to read, -EIO for fail to read.

Variable Documentation

◆ pfd1

int pfd1[2]
static

◆ pfd2

int pfd2[2]
static