Location:
Search - pthread mutex
Search list
Description:
Introduction
In this project, we will design a programming solution to the bounded-buffer problem using the producer and consumer processes . The solution uses three semaphores: empty and full, which count the number of empty and full slots in the buffer, and mutex, which is a binary (or mutual exclusive) semaphore that protects the actual insertion or removal of items in the buffer. For this project, standard counting semaphores will be used for empty and full, and, rather than a binary semaphore, a mutex lock will be used to represent mutex. The producer and consumer – running as separate threads – will move items to and from a buffer that is synchronized with these empty, full, and mutex structures. You are required to use the pthread package to solve this problem in this project.
And there can be several producers/consumers as many as you want.
-Introduction In this project, we will design a programming solution to the bounded-buffer problem using the producer and consumer processes. The solution uses three semaphores: empty and full, which count the number of empty and full slots in the buffer, and mutex, which is a binary (or mutual exclusive) semaphore that protects the actual insertion or removal of items in the buffer. For this project, standard counting semaphores will be used for empty and full, and, rather than a binary semaphore, a mutex lock will be used to represent mutex. The producer and consumer- running as separate threads- will move items to and from a buffer that is synchronized with these empty, full, and mutex structures. You are required to use the pthread package to solve this problem in this project.And there can be several producers/consumers as many as you want.
Platform: |
Size: 96256 |
Author: MidnightD |
Hits:
Description: linux下的多线程的创建及信号同步,信号量,互斥量-under linux to create multi-threaded and signal synchronization, semaphores, mutex volume
Platform: |
Size: 26624 |
Author: wuqian |
Hits:
Description: Generic template class library for message queue implementation, uses pthread mutex.
Platform: |
Size: 3072 |
Author: zzbao |
Hits:
Description: This program is written to explain pthread creation and destroy and its function. How to handle mutex and blocking etc-This program is written to explain pthread creation and destroy and its function. How to handle mutex and blocking etc..
Platform: |
Size: 1024 |
Author: Chanaka Hangilipola |
Hits:
Description: 基于ARM9的Linux多线程应用程序。生产者写入缓冲区和消费者从缓冲区读数的具体流程,生产者首先获得互斥锁,并且判断写指针+1后是否等于读指针,如果相等则进入等待状态,等候条件变量notfull;如果不等则向缓冲区中写入一个整数,并且设置条件变量为notempty,最后释放互斥锁。消费者线程与生产者线程类似。-ARM9-Linux-based multi-threaded applications. Producers and consumers into a buffer from the buffer readings of specific processes, producers first obtain a mutex lock, and to determine whether the write pointer is equal to+1 after reading pointer, if the same may enter the wait state, waiting for condition variables notfull if the ranging from the buffer to write to an integer, and set the condition variable notempty, the final release mutex. Consumer thread and producers similar thread.
Platform: |
Size: 1024 |
Author: 刘冉 |
Hits:
Description: 互斥量的简单应用,使用互斥量是实现多线程程序中的同步访问的另一种手段
-Mutex amount of simple applications using the exclusive capacity to achieve simultaneous multi-threaded program in an alternative means of access
Platform: |
Size: 34816 |
Author: 伍超 |
Hits:
Description: linux多线程编程的一个例子。里面用到了互斥锁。生产者/消费者模型。-linux an example of multi-threaded programming. Which uses a mutex. Producer/consumer model.
Platform: |
Size: 3072 |
Author: sds |
Hits:
Description: 用线程互斥锁实现生产者消费者,生产者生产供消费者消费- pthread mutex make up the producter and consumer
Platform: |
Size: 1024 |
Author: 陈龙 |
Hits:
Description: pthread mutex initializer for two processes
Platform: |
Size: 1024 |
Author: pudn17 |
Hits:
Description: 主要将有线程的互斥锁和生产者消费者等功能的复习总结。数据池的封装等。-Major will have a thread mutex and features such as producers and consumers of the review summary.
Platform: |
Size: 6144 |
Author: zengjin |
Hits:
Description: For those wishing to develop multi-threaded applications in a C++ class oriented
environment. This library allows creation of threads as classes as well as
access to multi-threaded programming tools as class abstractions. Even if the
basic programming paradigm is non class oriented, the availability of the MutEx,
Semaphore and Condition tools in a class instance can still be used.
-This project will compile to a dynamically loaded library that can be used when
developing multi-threaded applications in C++. The pthreadcc library is based
on the existing pthread library available in most UNIX installations. The
library defines a series of classes that can be used to implement a range of
thread based tools as well as a class that represents an extra thread. This
class library was developed by Jason But at Monash University
Platform: |
Size: 16384 |
Author: 李东 |
Hits:
Description: 哲学家进餐问题
#include<stdio.h>
#include<semaphore.h>
#include<pthread.h>
//宏定义信号量个数为5,宏定义0表示思考,宏定义1表示饿,宏定义2表示吃,宏定义(ph_num+4) N表示左,宏定义(ph_num+1) N表示右
#define N 5
#define THINKING 0
#define HUNGRY 1
#define EATING 2
#define LEFT (ph_num+4) N
#define RIGHT (ph_num+1) N
//声明互斥锁 ,声明数组
sem_t mutex
sem_t S[N]
//声明操作函数,取叉函数,放叉函数,测试函数
void * philospher(void *num)
void takeFork(int)
void putFork(int)
void test(int)
int state[N] -the question about lunch
Platform: |
Size: 1024 |
Author: cc |
Hits:
Description: 经典的互斥锁线程例子,使用 pthread 的互斥锁机制,使得程序运行的结果正确,使用 pthread 线程库创建两个线程,两个线程都要访问共享变量counter,按照源程序的逻辑,两个线程各循环 5 次,每次循环对 counter 变量加 1,最后打印的结果是 10。-The classic example of mutex thread using pthread mutex lock mechanism, so that the results of the program is running correctly, use pthread threading library to create two threads, two threads must access a shared variable counter, according to the source logic, two threads each cycle five times, each time adding a circulation of counter variables, the results of the final print is 10.
Platform: |
Size: 1024 |
Author: zjuuuu |
Hits: