Operating System
seagullyoyo
for the load your god is with you whereever you go
展开
-
PV生产者消费者问题
#define N 100typedef semaphore int;semaphore muxtex = 1; //临界区锁,用于防止生产者消费者同时访问临界资源 semaphore full = 0; //有面包的格子数 semaphore empty = N; //没面包的格子数 void consumer(void){ int item; while原创 2014-08-27 15:31:13 · 1737 阅读 · 0 评论 -
PV读者写者问题
semaphore mutex = 1;semaphore db = 1;int readercount = 0;void Reader(){ while(true) { P(mutex); readercount ++; if(readercount == 1) P(db); V(mutex); //读数据 P(mutex); //读完原创 2014-08-30 16:40:11 · 741 阅读 · 0 评论 -
多线程编程学习笔记-interlocked
#include #include #include volatile long g_nLoginCount;unsigned int __stdcall Fun(void *pPM);const int THREAD_NUM = 50;DWORD WINAPI ThreadFun(void *pPM){ Sleep(100); //g_nLoginCount++; Int原创 2014-09-01 14:40:22 · 407 阅读 · 0 评论