mutex « pthread « C Q&A

Home
C Q&A
1.assembly
2.buffer
3.Card
4.Cast
5.compile
6.console
7.const
8.constructor
9.database
10.Date
11.Debug
12.Design
13.Development
14.DLL
15.encrypt
16.enum
17.eof
18.Event
19.fork
20.Format
21.gcc
22.gdb
23.graph
24.graphics
25.gui
26.Holiday Event
27.image
28.IP
29.iterator
30.macro
31.makefile
32.malloc
33.Menu
34.mysql
35.network
36.openssl
37.operator
38.password
39.pipe
40.preprocessor
41.printf
42.pthread
43.Regular expression
44.scanf
45.semaphore
46.SerialPort
47.server
48.Socket
49.sql
50.SQLserver
51.sscanf
52.std
53.stdin
54.stdout
55.stl
56.strcmp
57.stream
58.switch
59.Template
60.thread
61.timer
62.unix
63.video
64.Virtual
65.visualstudio
66.winapi
67.windows
68.xml
C Q&A » pthread » mutex 

1. C - Pthreads mutex and general headaches    stackoverflow.com

Hey guys I was wondering if someone could provide a little help. I've been trying to teach myself pthreads and with that, mutex locks to get threads running together and using the ...

2. C Pthreads mutex values?    stackoverflow.com

I am writing a program with a few critical sections. The thing is I need to check the value of a mutex in an if statement. I would like to do ...

3. C thread-mutex codes errors?    stackoverflow.com

Here is the code:

....
typedef struct {
  int buf[10];
  long head, tail;
  int full, empty;
  pthread_mutex_t *mut;
  pthread_cond_t *notFull, *notEmpty;
} queue;

int main(){
  queue *que;
  pthread_t ...

4. pthread_mutex_unlock not atomic    stackoverflow.com

I've the following source code (adapted from my original code):

#include "stdafx.h"
#include <stdlib.h> 
#include <stdio.h> 

#include "pthread.h"

#define MAX_ENTRY_COUNT 4  

int  entries = 0;  
bool start = false;

bool send_active = ...

5. What happens to Mutex when the thread which acquired it exits?    stackoverflow.com

Suppose there are two threads, the main thread and say thread B(created by main). If B acquired a mutex(say pthread_mutex) and it has called pthread_exit without unlocking the lock. So ...

6. Static pthreads mutex initialization    stackoverflow.com

Using pthreads, how would one, in C, initialize a static array of mutexes? For a single static mutex, it seems I can use PTHREAD_MUTEX_INITIALIZER. But what about an static array of them? ...

7. Implementing a FIFO mutex in pthreads    stackoverflow.com

I'm trying to implement a binary tree supporting concurrent insertions (which could occur even between nodes), but without having to allocate a global lock or a separate mutex or mutexes for ...

8. Finding out statuses of active threads from the current thread. (Implementation of Robust Mutexes)    stackoverflow.com

We are trying to port some code from Solaris to HPUX. While Solaris uses it's own thread API, HPUX uses the Pthread API. One problem that we faced during migration is ...

9. How to use mutexes in C    stackoverflow.com

I am confused about use of multiple mutexes in C.

int main() {

        pthread_t thread1;
        char *message1 ...

10. pthread_mutex_unlock() returns 1    bytes.com

11. Help in Pthread and Mutex program    cboard.cprogramming.com

Code: #include #include #include #include #define N 3 /*Declaration*/ void *writer(int n); void *reader(int n); void clean(); /*Init*/ pthread_mutex_t mutex,mutex1; int main(int argc, char **argv) { int i; pthread_t thrR[N]; pthread_t thrW[N]; pthread_mutex_init(&mutex,NULL); pthread_mutex_init(&mutex1,NULL); for(i=0;i

12. pthread_mutex_init    cboard.cprogramming.com

13. pthread mutex problemos    cboard.cprogramming.com

#include #include #include #include pid_t pid; pthread_mutex_t imutex; pthread_mutexattr_t attr; int main(int argc, char **argv) { pthread_mutexattr_settype(&attr ,PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&imutex,&attr); pid = fork(); printf("pid %d",pid); if (pid == 0){ while(1){ pthread_mutex_lock(&imutex); printf("\ni am the child\n"); pthread_mutex_unlock(&imutex); } } else{ while(1){ pthread_mutex_lock(&imutex); printf("\ni am the parent\n"); pthread_mutex_unlock(&imutex); } } return 0; }

14. help with pthread_mutex_t    cboard.cprogramming.com

15. pthread_mutex_t    cboard.cprogramming.com

16. seg fault on pthread_mutex_init    cboard.cprogramming.com

17. Question about pthread_mutex_destroy    forums.devshed.com

Isn't it obvious from the manual page ? Like any other consumable resource, like say calling malloc and then calling free, you're probably going to get away with sloppy code which doesn't clear up properly, especially in smaller programs. But problems associated with such poor code usually show up at the most inconvenient times (during presentations, 1 day after delivery to ...

18. Help with dynamic allocated pthread_mutex?    forums.devshed.com

I created a dynamic allocated data structure (link list nodes) that is accessed by many threads and I would like to protect data of each nodes using mutex variable. Here's what my data record for a node looks like: typedef struct node_s { pthread_mutex_t node_mutex; int node_val; struct node_s *next; } node; A node's data is dynamically allocated using malloc() and ...

19. Pthread_mutex_initializer    forums.devshed.com

20. PTHREAD_MUTEX_INITIALIZER question / what to protect    forums.devshed.com

Hi there, I have a question about protecting shared data between threads. I have written a threaded tcp server. and it reads and writes to vectors. i'm unable to find any clear documentation on the web on this. What is this created mutex protecting ? Do i have to create a new mutex for every global variable ? this is a ...

21. A problem with pthread mutex    forums.devshed.com

Hello, I'm trying to implement pthread mutex. The follwing small program is supposed to ask for a name and print it out: /////////////////////////// #include pthread_mutex_t name1=PTHREAD_MUTEX_INITIALIZER; #define NUM_THREADS 2 pthread_t threads[NUM_THREADS]; void *Print(void *threadid) { char name[20]; cout<<"\n Please Enter Your User Name ,User "<>name; cout<<"\n"<

22. pthread and mutex    forums.devshed.com

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.