#include <semaphore.h>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <fcntl.h>
#include <string>
using namespace std;
int main()
{
int value=0;
sem_t *Sem;
string sName="/Pole";
Sem = sem_open(sName.c_str(),O_CREAT,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,1);
int i=sem_unlink(sName.c_str());
sem_getvalue(Sem,&value);
if(Sem == SEM_FAILED || Sem == NULL)
{
cout<<"Failed!"<<endl;
exit(-1);
}
else
{
cout<<"SUccessfully"<<endl;
}
for (long i = 1; i < 5; i++)
{
sem_wait(Sem);
for (long Count = 1; Count < 6; ++Count)
{
sem_getvalue(Sem,&value);
cout<<"Preocess 2 In! "<< Count <<endl;
sem_getvalue(Sem,&value);
sleep(1);
}
cout<<"============="<<endl;
sem_post(Sem);
sleep(3);
}
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
share-thread-linux.tar.gz_between
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 190 浏览量
2022-09-14
18:03:45
上传
评论
收藏 1KB GZ 举报
温馨提示
共4个文件
c:4个
testing share infomation between different process. very easy.
资源推荐
资源详情
资源评论
收起资源包目录
share-thread-linux.tar.gz (4个子文件)
testread.c 616B
test2.c 805B
test1.c 752B
testwriter.c 653B
共 4 条
- 1
资源评论
小贝德罗
- 粉丝: 71
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功