UNIX系统支持在不同进程间共享打开文件。内核使用3种数据结构表示打开文件,它们之间的关系决定了文件共享方面一个进程对另一个进程可能产生的影响。 内核维持了3个表,即进程表,文件表和v节点表。具体如下: 1>每个进程在进程表中都有一个纪录项,记录项中包含一张打开文件描述符表,每个描述符占用一...
分类:
其他好文 时间:
2015-03-09 00:20:35
阅读次数:
169
1. open() O_RONLY O_WONLY O_RDWR 返回值为 文件描述符fd2. creat() 创建新文件,这个函数的产生是因为最开始open函数没有O_CREAT 功能,所以单独开发的该函数注:不是create,没有e3. read() 读取fd对应的文件内容4. write(.....
分类:
其他好文 时间:
2015-02-28 00:14:06
阅读次数:
165
// apue.h
#ifndef APUE_SUNYJ
#define APUE_SUNYJ void err_quit(const char *fmt, ...);
void err_sys(const char *fmt, ...); #endif
// error.cpp
#include ...
分类:
系统相关 时间:
2015-02-10 18:37:05
阅读次数:
495
#include struct msg { struct msg *m_next; /* ... more stuff here ... */ int m_id;
}; msg* workq;
pthread_cond_t qready = PTHREAD_COND_INITIALIZER;
pth...
分类:
其他好文 时间:
2015-02-09 19:48:56
阅读次数:
293
http://www.apuebook.com/errata2e.html Welcome to the web site dedicated to the support of the second edition of Advanced Programming in the UNIX® Envi...
分类:
其他好文 时间:
2015-02-07 18:50:47
阅读次数:
228
// threads/mutex1.c 11-5
#include #include #include struct foo { int f_count; pthread_mutex_t f_lock; int f_id; /* ... more stuff her...
分类:
编程语言 时间:
2015-02-07 18:42:17
阅读次数:
227
今天看《Unix环境高级编程》的fork函数与vfork函数时,看见一个copy-on-write的名词,貌似以前也经常听见别人说过这个,但也一直不明白这究竟是什么东西。所以就好好在网上了解了下,也算明白个大概,先记录下来. 转载自http://www.cnblogs.com/biyeymy...
分类:
其他好文 时间:
2015-02-07 17:17:28
阅读次数:
117
// threads/exitstatus.c 11-2
#include "apue.h"
#include void* thr_fn1(void* arg)
{ printf("thread 1 returning\n"); /* return a variable of type void* ...
分类:
编程语言 时间:
2015-02-06 23:09:43
阅读次数:
197
程序清单11-1打印线程ID// threads/threadid.c 11-1
#include "apue.h"
#include pthread_t ntid; void printids(const char* s)
{ printf("%d ", (unsigned int)ntid); ...
分类:
编程语言 时间:
2015-02-06 21:43:01
阅读次数:
339
原文网址:http://blog.csdn.net/hubbybob1/article/details/40859835大家好,从这周开始学习apue《UNIX环境高级编程第三版》,在此,我要感谢网易的一个工程师朋友和室友,没有他们,我不会开始真正的学习这本书,希望大家以后开始慢慢进步。废话少说,直...
分类:
其他好文 时间:
2015-02-06 21:40:22
阅读次数:
197