• 互斥对象必须声明;声明后必须初始化

    The mutex object must be declared; once declared, it must be initialized.

    youdao

  • 现在线程需要使用两个互斥量

    Now, imagine that two threads want to use them. Thread one does this.

    youdao

  • 占有这个惟一物体过程就叫做锁定或者获得互斥量

    Once you have it, no one can take it away from you until you put it down. The process of picking up the unique object is called locking, or acquiring, the mutex.

    youdao

  • 如果可能设计程序决不锁定一个已经锁定的互斥

    If possible, just design your program never to re-lock a mutex it already has.

    youdao

  • 所以我们更进一步,在产生随机数地方一个互斥

    So, let's say we go ahead and add a mutex that surrounds the random number generator.

    youdao

  • 主线程:锁定互斥量threadcount

    Main thread: Lock mutex and increment threadcount.

    youdao

  • 这样问题一个简单解决办法保证相同顺序获得互斥

    One simple solution to problems like this is to ensure that locks are always acquired in the same order.

    youdao

  • 创建使用互斥过程仅仅是开始一个线程的过程要稍微复杂一些

    The procedure for creating and using a mutex is a bit more complicated than the procedure for starting a thread.

    youdao

  • pthread_cond_wait被调用后,它解锁互斥量停止线程执行

    When invoked, pthread_cond_wait unlocks the mutex and then pauses execution of its thread.

    youdao

  • 这个了一些新的工作;锁定一个叫做count _ mutex的互斥

    This routine does something new; it locks a mutex called, creatively enough, count_mutex.

    youdao

  • 另外还可以使用递归类型互斥这种互斥量允许同一个互斥量锁定多次

    Otherwise, you can use the "recursive" mutex type, which allows the holder of the lock to lock the same mutex multiple times.

    youdao

  • 之后创建一个新的线程同时threadcount;在完成之后,它解锁互斥

    After locking that, it creates a new thread and increments threadcount; after it's done, it unlocks the mutex.

    youdao

  • 如果线程2运行就要锁定count _ mutex,而这个互斥量已经线程1占有了

    If thread two runs, it'll want to lock count_mutex, which is held by thread one.

    youdao

  • 如果线程1运行就要锁定rand _ mutex,可是这个互斥量已经线程2阻塞了。

    If thread one runs, it'll want to lock rand_mutex, which is held by thread two.

    youdao

  • 如果互斥threadcount的值减小到了我们知道这时已经没有线程在运行了,退出程序了。

    If the decrement leaves threadcount at zero, we know that there are no threads running, so it's time to exit.

    youdao

  • 不再使用互斥时,可以调用pthread _ mutex_destroy来释放初始化过程分配资源

    When you're done with a mutex, you can release any resources allocated during initialization with a call to pthread_mutex_destroy .

    youdao

  • 这个坏程序开发者起初想法好的,即真正需要使用之前锁定这些互斥但是他却直到运行结束解锁

    The hapless developer of this monstrosity came up with the clever idea of only locking things when they are actually about to be used, but deferring unlocking until the end of a run.

    youdao

  • 最后一个线程调用pthread_cond_wait而被唤醒第一件事就是重新锁定最初调用解锁那个互斥量

    Finally, the first thing any thread tries to do when waking up from pthread_cond_wait is re-lock the mutex it unlocked when initially called.

    youdao

  • 如果调用pthread_create前面改变threadcount值代码去掉,那么互斥代码中间剩下减小计数值的语句了。

    If you moved the change in threadcount in front of the call to pthread_create , then the mutex code could just surround the actual decrement.

    youdao

  • 函数pthread_cond_wait主要就是用于阻塞线程的,两个参数第一个指向条件指针第二个是一个锁定了的互斥量

    The function primarily used for this is pthread_cond_wait . It takes two arguments; the first is a pointer to a condition variable, and the second is a locked mutex.

    youdao

  • 如果调用线程并不拥有这个互斥信号,那么这个函数执行将会失败

    If the calling thread has no ownership of this mutex, this function fails.

    youdao

  • 这个方法允许设置互斥信号对象的相关属性

    This method allows you to set mutex object attributes.

    youdao

  • 内核可以使用互斥实现信号行为

    Mutexes are available in the kernel as a way to accomplish semaphore behavior.

    youdao

  • 释放一个不再需要互斥信号对象,可以使用pthread _ mutex_destroy 。

    To free a mutex object that is no longer needed, pthread_mutex_destroy is used.

    youdao

  • 拥有这个互斥信号线程不再需要时候,可以调用ReleaseMutex,以便将它释放系统

    ReleaseMutex is called when the owning thread no longer needs the mutex, and it can be conveniently released to the system.

    youdao

  • 基本知识信号互斥线程必需的。

    Basic knowledge of semaphores, Mutex, and threads are required.

    youdao

  • 厕所重要例子二进制信号互斥区别

    Difference between Binary Semaphore and Mutex in the toilet key example?

    youdao

  • 希望看到这里应该二进制信号计数信号互斥区别有了清晰的认识。

    Hopefully you should now be clear about the core differences between the Binary Semaphore, General (counting) Semaphore and the Mutex.

    youdao

  • 希望看到这里应该二进制信号计数信号互斥区别有了清晰的认识。

    Hopefully you should now be clear about the core differences between the Binary Semaphore, General (counting) Semaphore and the Mutex.

    youdao

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定