ChinaUnix.net
相关文章推荐:

semaphore 汇编 实现

想了一下,没有办法呢

by 太平绅士 - C/C++ - 2015-03-19 23:15:09 阅读(7808) 回复(16)

相关讨论

作者:李强,华清远见嵌入式学院讲师。

semaphore是内核中比较重要和常用的同步方式之一,他主要的特点是实现了Sleep机制下的同步。也就是当获取一个semaphore但是又不能立刻获取的时候,他使当前的执行...

by xi_liang - 移动操作系统 - 2011-12-20 09:44:20 阅读(494) 回复(0)

因为现在所用的平台只有semaphore, 想用它实现一个lock,具有recursive性质的, 也就是只能lock其他线程,自己不会lock自己的那种锁。 类似于pthread_mutex_t加上PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP属性的那种。 请教高人有什么好的算法?

by 飞灰橙 - C/C++ - 2005-12-05 14:53:58 阅读(2187) 回复(2)

求教:我在sco unix上用semaphore的sem_init函数实现互斥锁系统返回operatoe not permtted的错误,但我用系统的sem.h中的semget函数则可以实现,不知道是何原因引起的,请赐教!

by termjoy - 其他UNIX - 2005-12-09 17:29:32 阅读(1010) 回复(0)

在sco5.07下编译时出错: # g++ -o t -lgthreads -lsuds test.cpp WARNING: no SCO ELF identifying .note section in file 'libgthreads.so' Undefined first referenced symbol in file sem_init(posix_sem *, int, unsigned int)/usr/tmp/ccMClGlE.o sem_wait(posix_sem *) /usr/tmp/ccMClGlE.o sem_post(posix_sem *) /usr/tmp/ccMClGlE.o sem...

by softmachine - 其他UNIX - 2005-12-05 11:55:11 阅读(1435) 回复(6)

semaphores Remember file locking ? Well, semaphores can be thought of as really generic advisory locking mechanisms. You can use them to control access to files, shared memory , and, well, just about anything you want. The basic functionality of a semaphore is that you can either set it, check it, or wait until it clears then set it ("test-n-set"). No matter how complex the stuff that follo...

by 我爱spring - Linux文档专区 - 2007-06-27 20:42:12 阅读(500) 回复(0)

There are a lot of different ways that people use memcached and PHP. The most common of which is probably your basic set and get to cache data from your database.
----------------
有许多方式使用memcache和PHP, 其中最常见方式的可能是set get 是从数据库里取数据缓存起来

by zipalpha - Web开发 - 2011-12-22 08:54:28 阅读(831) 回复(0)

Difference between Mutex and semaphore Source: http://koti.mbnet.fi/niclasw/Mutexsemaphore.html 先看看网上著名的厕所理论的描述: Mutex: Is a key to a toilet. One person can have the key - occupy the toilet - at the time. When finished, the person gives (frees) the key to the next person in the queue. Officially: "Mutexes are typically used to serialise access to a section of re-entrant code that...

by jerrykinki - Linux文档专区 - 2009-02-19 17:06:21 阅读(872) 回复(0)

看linus在N久前曾经提到过如下场景(2.4的年代?), CPU1 -- down(sem);kfree();(或者sem是在栈上分配,而且down之后紧跟return) CPU2 -- up(sem); 他说这样会出现问题,因此提出了completion. 如果说多CPU上up和down可能会并发执行,那为什么在单CPU上就不存在这个问题呢?一直没想明白 还有个问题,semaphore结构和2.6.16内核中新的mutex结构是什么关系? 请各位指教,谢谢

by iterator - 内核源码 - 2008-05-21 10:11:30 阅读(2196) 回复(5)

struct completion: 有的时候我们需要在一个线程里面发起另外一个线程里的某些动作,然后等待另外一个线程的动作完成.这个我们可以用completion.这是信号量的一种简单实现. 完成变量是信号量的一种简单的实现。当一个任务运行需要请求某个资源或条件的情况下,wait_for_completion()函数将此任务放入等待队列,等待。另外一个任务使用完这个资源通过complete()函数发送一个完成变量,通知等待队列中的这个任务继续执行。 完成变量...

by maddrone - Linux文档专区 - 2008-03-17 16:36:58 阅读(751) 回复(0)

最近看了看System V semaphore, 刚开始还有点晕,后来发现如果自己封装一下还是比较容易理解的,下面的代码只是简单的例子,用于帮助自己理解这些操作,不保证能通过编译 :) #include sys/types.h> #include sys/ipc.h> #include sys/sem.h> union semun { int val; struct semid_ds *buf; unsigned short *array; struct seminfo *__buf; }; // create the semaphore set, // if key is IPC_PRIVATE, the se...

by mengzhao - Linux文档专区 - 2008-01-30 15:31:41 阅读(583) 回复(0)