当前位置: 技术问答>linux和unix
信号量 段错误 编译过了,运行提示段错误!!! 大神们,急救啊!!!!
来源: 互联网 发布时间:2017-01-04
本文导语: #define __LIBRARY__ #include #include #include #include #include #include #include #define MAX 1000 int main(){ int i,j,k; int count; int temp1[10],temp2[10]; int num,last_num; int num_cp = 0; int pid = 100; FILE *gjw = NULL; sem_t *empty, *m...
#define __LIBRARY__
#include
#include
#include
#include
#include
#include
#include
#define MAX 1000
int main(){
int i,j,k;
int count;
int temp1[10],temp2[10];
int num,last_num;
int num_cp = 0;
int pid = 100;
FILE *gjw = NULL;
sem_t *empty, *mutex, *full;
empty = sem_open( "empty", O_CREAT, 0644, MAX);
mutex = sem_open( "mutex", O_CREAT, 0644, 1);
full = sem_open( "full", O_CREAT, 0644, 0);
gjw = fopen( "guojunwu.txt", "wb+");
for( i = 0; i 0) {
pid = fork();
num_cp++;
}
}
//父进程 Producer
if( pid > 0) {
for( j = 0; j
#include
#include
#include
#include
#include
#include
#include
#define MAX 1000
int main(){
int i,j,k;
int count;
int temp1[10],temp2[10];
int num,last_num;
int num_cp = 0;
int pid = 100;
FILE *gjw = NULL;
sem_t *empty, *mutex, *full;
empty = sem_open( "empty", O_CREAT, 0644, MAX);
mutex = sem_open( "mutex", O_CREAT, 0644, 1);
full = sem_open( "full", O_CREAT, 0644, 0);
gjw = fopen( "guojunwu.txt", "wb+");
for( i = 0; i 0) {
pid = fork();
num_cp++;
}
}
//父进程 Producer
if( pid > 0) {
for( j = 0; j