文件名称:UNIXCcode
- 所属分类:
- Linux/Unix编程
- 资源属性:
- [C/C++] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 147kb
- 下载次数:
- 0次
- 提 供 者:
- netd****
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
用C语言编写的Unix代码实例 供大家参考 -#include <sys/sem.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <stdio.h>
#include <sys/stat.h>
#define VERIFYERR(a, b) if (a) fprintf(stderr, " s failed.\n", b) else fprintf(stderr, " s success.\n", b)
void main(int argc, char*argv[])
{
int semid, index, i
struct semid_ds ds
unsigned short array[100]
if (argc != 4) return
semid = atoi(argv[1])
index = atoi(argv[2])
if (argv[3][0] == c )
{ /* 创建信号量*/
VERIFYERR(semget(semid, index, 0666|IPC_CREAT|IPC_EXCL) < 0, "Create sem")
}
else if (argv[3][0] == d )
{ /* 删除消息队列*/
VERIFYERR(semctl(semid, 0, IPC_RMID, NULL) < 0, "Delete sem")
}
else if (argv[3][0] == v )
{ /* 查看信号量信息*/
fprintf(stderr, "T ID INDEX SEMVAL SEMPID SEMNCNT SEMZCNT\n")
fprintf(stderr, "s 6d 6d 10d 10d 10d 10d\n",
semid, /* 标识号*/
index, /* 信号量序号*/
semctl(semid, index, GETVAL), /* 信号量值*/
semct > Downloads > 源码/资料
#include <sys/types.h>
#include <sys/ipc.h>
#include <stdio.h>
#include <sys/stat.h>
#define VERIFYERR(a, b) if (a) fprintf(stderr, " s failed.\n", b) else fprintf(stderr, " s success.\n", b)
void main(int argc, char*argv[])
{
int semid, index, i
struct semid_ds ds
unsigned short array[100]
if (argc != 4) return
semid = atoi(argv[1])
index = atoi(argv[2])
if (argv[3][0] == c )
{ /* 创建信号量*/
VERIFYERR(semget(semid, index, 0666|IPC_CREAT|IPC_EXCL) < 0, "Create sem")
}
else if (argv[3][0] == d )
{ /* 删除消息队列*/
VERIFYERR(semctl(semid, 0, IPC_RMID, NULL) < 0, "Delete sem")
}
else if (argv[3][0] == v )
{ /* 查看信号量信息*/
fprintf(stderr, "T ID INDEX SEMVAL SEMPID SEMNCNT SEMZCNT\n")
fprintf(stderr, "s 6d 6d 10d 10d 10d 10d\n",
semid, /* 标识号*/
index, /* 信号量序号*/
semctl(semid, index, GETVAL), /* 信号量值*/
semct > Downloads > 源码/资料
(系统自动生成,下载前可以参看下载内容)
下载文件列表
UNIXCcode\code\chapter10\jmp1.c
.........\....\.........\sig1.c
.........\....\.........\sig2.c
.........\....\.........\sig3.c
.........\....\.........\time1.c
.........\....\.........\time2.c
.........\....\.........\time3.c
.........\....\.........\time4.c
.........\....\.........\timeout1.c
.........\....\.........\timeout2.c
.........\....\.........\timeout3.c
.........\....\........1\fifo1.c
.........\....\.........\fifo2.c
.........\....\.........\pipe1.c
.........\....\.........\pipe2.c
.........\....\.........\pipe3.c
.........\....\.........\pipe4.c
.........\....\........2\ipcmsg
.........\....\.........\ipcmsg.c
.........\....\.........\msg1
.........\....\.........\msg1.c
.........\....\.........\msg2
.........\....\.........\msg2.c
.........\....\........3\ipcsem.c
.........\....\.........\sema.c
.........\....\.........\semb.c
.........\....\........4\ipcshm.c
.........\....\.........\shm1.c
.........\....\.........\shm2.c
.........\....\........5\http1.c
.........\....\.........\http2.c
.........\....\.........\http3.c
.........\....\.........\http5.c
.........\....\.........\http6.c
.........\....\.........\makefile
.........\....\.........\tcp1.c
.........\....\.........\tcp2.c
.........\....\.........\tcpopt.c
.........\....\.........\transip.c
.........\....\.........\transip1.c
.........\....\.........\transport.c
.........\....\.........\transserv.c
.........\....\........6\desktop1.c
.........\....\.........\makefile
.........\....\.........\ser1.c
.........\....\.........\trans1.c
.........\....\.........\udpk1.c
.........\....\.........\udps1.c
.........\....\........7\inet1.c
.........\....\.........\inet2.c
.........\....\.........\makefile
.........\....\.........\proxy1.c
.........\....\.........\proxy2.c
.........\....\.........\proxy3.c
.........\....\.........\tcpto1.c
.........\....\.........\tcpto2.c
.........\....\........8\con1.c
.........\....\.........\config.ini
.........\....\.........\makefile
.........\....\.........\str1.c
.........\....\.........\str2.c
.........\....\........9\config.ini
.........\....\.........\htservice.c
.........\....\.........\htservice1.c
.........\....\.........\htservice2.c
.........\....\.........\makefile
.........\....\.......20\config.ini
.........\....\.........\file1.c
.........\....\.........\file2.c
.........\....\.........\filesys1.c
.........\....\.........\filesys1sco.c
.........\....\.........\filesys2.c
.........\....\.........\filesys2sco.c
.........\....\.........\makefile
.........\....\.........\makefiledll
.........\....\.........\monitor1.c
.........\....\.........\monitor2.c
.........\....\.........\monitor3.c
.........\....\.........\msg1.c
.........\....\.........\msg2.c
.........\....\.........\opendll.c
.........\....\.........\process1.c
.........\....\.........\process2.c
.........\....\.........\time1.c
.........\....\.........\time2.c
.........\....\........1\config.ini
.........\....\.........\login1.c
.........\....\.........\makefile
.........\....\.........\trans1.c
.........\....\.......3\d1.c
.........\....\........\d2.c
.........\....\........\main.c
.........\....\........\pr1.c
.........\....\........\pr2.c
.........\....\........\tdl.c
.........\....\........\tds.c
.........\....\.......4\file1.c
.........\....\........\file1sco.c
.........\....\........\ls1.c
.........\....\.......5\buf1.c
.........\....\.........\sig1.c
.........\....\.........\sig2.c
.........\....\.........\sig3.c
.........\....\.........\time1.c
.........\....\.........\time2.c
.........\....\.........\time3.c
.........\....\.........\time4.c
.........\....\.........\timeout1.c
.........\....\.........\timeout2.c
.........\....\.........\timeout3.c
.........\....\........1\fifo1.c
.........\....\.........\fifo2.c
.........\....\.........\pipe1.c
.........\....\.........\pipe2.c
.........\....\.........\pipe3.c
.........\....\.........\pipe4.c
.........\....\........2\ipcmsg
.........\....\.........\ipcmsg.c
.........\....\.........\msg1
.........\....\.........\msg1.c
.........\....\.........\msg2
.........\....\.........\msg2.c
.........\....\........3\ipcsem.c
.........\....\.........\sema.c
.........\....\.........\semb.c
.........\....\........4\ipcshm.c
.........\....\.........\shm1.c
.........\....\.........\shm2.c
.........\....\........5\http1.c
.........\....\.........\http2.c
.........\....\.........\http3.c
.........\....\.........\http5.c
.........\....\.........\http6.c
.........\....\.........\makefile
.........\....\.........\tcp1.c
.........\....\.........\tcp2.c
.........\....\.........\tcpopt.c
.........\....\.........\transip.c
.........\....\.........\transip1.c
.........\....\.........\transport.c
.........\....\.........\transserv.c
.........\....\........6\desktop1.c
.........\....\.........\makefile
.........\....\.........\ser1.c
.........\....\.........\trans1.c
.........\....\.........\udpk1.c
.........\....\.........\udps1.c
.........\....\........7\inet1.c
.........\....\.........\inet2.c
.........\....\.........\makefile
.........\....\.........\proxy1.c
.........\....\.........\proxy2.c
.........\....\.........\proxy3.c
.........\....\.........\tcpto1.c
.........\....\.........\tcpto2.c
.........\....\........8\con1.c
.........\....\.........\config.ini
.........\....\.........\makefile
.........\....\.........\str1.c
.........\....\.........\str2.c
.........\....\........9\config.ini
.........\....\.........\htservice.c
.........\....\.........\htservice1.c
.........\....\.........\htservice2.c
.........\....\.........\makefile
.........\....\.......20\config.ini
.........\....\.........\file1.c
.........\....\.........\file2.c
.........\....\.........\filesys1.c
.........\....\.........\filesys1sco.c
.........\....\.........\filesys2.c
.........\....\.........\filesys2sco.c
.........\....\.........\makefile
.........\....\.........\makefiledll
.........\....\.........\monitor1.c
.........\....\.........\monitor2.c
.........\....\.........\monitor3.c
.........\....\.........\msg1.c
.........\....\.........\msg2.c
.........\....\.........\opendll.c
.........\....\.........\process1.c
.........\....\.........\process2.c
.........\....\.........\time1.c
.........\....\.........\time2.c
.........\....\........1\config.ini
.........\....\.........\login1.c
.........\....\.........\makefile
.........\....\.........\trans1.c
.........\....\.......3\d1.c
.........\....\........\d2.c
.........\....\........\main.c
.........\....\........\pr1.c
.........\....\........\pr2.c
.........\....\........\tdl.c
.........\....\........\tds.c
.........\....\.......4\file1.c
.........\....\........\file1sco.c
.........\....\........\ls1.c
.........\....\.......5\buf1.c