#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/ipc.h>
#include<sys/sem.h>
#include<unistd.h>
#include<time.h>
int semid;
union senum{
int val;
};
void wait_for_2fork(int no)
{
int left = no;
int right = (no+1)%5;
struct sembuf sbs[2] = {
{left,-1,0}, {right,-1,0} };
semop(semid,sbs,2);
}
void put_for_2fork(int no)
{
int left = no;
int right = (no+1)%5;
struct sembuf sbs[2] = {
{left,1,0}, {right,1,0} };
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载