Dear friends
I have a bit basic doubts in pointers and the structures inter relationships.
the first one.
static struct apvt {
int dead;
int pending;
int abouttograb;
}*agents=NULL;
what agents pointer is... (1 Reply)
Hi All,
I was given a format of a file, and was asked to write a program which displays the data contained in the file in that purticular format.
Its all so confusing.
Please find the example of the format as well the code I have written in the attachment.
I hope any one of u guyz can... (0 Replies)
Hi all!
I am working on unix systems.I am programming in c.
I have got some problems with pthread.when I use pthread_create to creat a thread it says:
(.text+0x3a): undefined reference to `pthread_create'.
same is the problm with pthread_kill.
Can anyone help me out here.
Thanks.
vij. (2 Replies)
hello
can any1 plz tell me about the system defined structures (like sysinfo) which wil give system and n/w charecteristics (ex: freeram in sysinfo). (1 Reply)
Hello,
I run my pthread code on Linux with 4 processors. However, the speed up is only 2 times.
The code is about solving equation (G+s(i)C)z(i)=B*us(i), i=1,...,n. Here G,C are m*m matrix, B*us(i) is a m*1 vector and s(i) are n different numbers. I need to solve the equation n times to... (2 Replies)
Hi All,
I am using the array of pointers and storing the address of string.This is a global list.
So i am using extern to give the reference of this list to another file and using reading the data from this string.
But list is being corrupted and string is missing some characters in... (2 Replies)
Hi all,
I wrote some code in c, using pthread (I configured the linker and compiler in eclipse IDE first).
#include <pthread.h>
#include "starter.h"
#include "UI.h"
Page* MM;
Page* Disk;
PCB* all_pcb_array;
void* display_prompt(void *id){
printf("Hello111\n");
return... (1 Reply)
Hello All,
I am having this issue...where I am actually having hard time understanding the problem:
The code is as follows:
#include<iostream.h>
void fxn(char*** var)
{
int i =4;
*var = (char**)malloc(i*sizeof(char*));
for(int j =0; j<4; j++)
{
*var = "name";
cout<<*var;... (6 Replies)
Hello,
I have a signal handler which manipulates a data structure. The data structure's operations aren't atomic. So if two threads/processes are in a critical section at the same time the data structure will be broken.
With threads you can avoid this stuff with semaphores etc.
However,... (10 Replies)
Discussion started by: littlegnome
10 Replies
LEARN ABOUT NETBSD
pthread_mutex_unlock
PTHREAD_MUTEX(3) BSD Library Functions Manual PTHREAD_MUTEX(3)NAME
pthread_mutex -- mutual exclusion primitives
LIBRARY
POSIX Threads Library (libpthread, -lpthread)
SYNOPSIS
#include <pthread.h>
int
pthread_mutex_init(pthread_mutex_t * restrict mutex, const pthread_mutexattr_t * restrict attr);
int
pthread_mutex_destroy(pthread_mutex_t *mutex);
int
pthread_mutex_lock(pthread_mutex_t *mutex);
int
pthread_mutex_trylock(pthread_mutex_t *mutex);
int
pthread_mutex_unlock(pthread_mutex_t *mutex);
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
DESCRIPTION
The pthread_mutex_init() function creates a new mutex, with attributes specified with attr. If attr is NULL, the default attributes are
used.
The macro PTHREAD_MUTEX_INITIALIZER can be used to initialize a mutex when the default attributes are appropriate and the mutex can be stati-
cally allocated. The behavior is similar to pthread_mutex_init() with attr specified as NULL, except that no error checking is done.
The pthread_mutex_destroy() function frees the resources allocated for mutex. It is possible to reinitialize a destroyed mutex, but unde-
fined behavior may follow if the destroyed object is otherwise referenced.
The pthread_mutex_lock() function locks mutex. If the mutex is already locked, the calling thread will block until the mutex becomes avail-
able. The error conditions may vary depending on the type of the mutex; see pthread_mutexattr(3) for additional details.
The pthread_mutex_trylock() function locks mutex. If the mutex is already locked, pthread_mutex_trylock() will not block waiting for the
mutex, but will return an error condition.
The pthread_mutex_unlock() function unlocks an acquired mutex. When operating with the default mutex type, undefined behavior follows if a
thread tries to unlock a mutex that has not been locked by it, or if a thread tries to release a mutex that is already unlocked.
RETURN VALUES
Upon success all described functions return zero. Otherwise, an error number will be returned to indicate the error.
ERRORS
pthread_mutex_init() may fail if:
[EAGAIN] The system lacks the resources to initialize another mutex.
[EINVAL] The value specified by attr is invalid.
[ENOMEM] The process cannot allocate enough memory to initialize another mutex.
pthread_mutex_destroy() may fail if:
[EBUSY] Mutex is locked by another thread.
[EINVAL] The value specified by mutex is invalid.
pthread_mutex_lock() may fail if:
[EDEADLK] A deadlock would occur if the thread blocked waiting for mutex.
[EINVAL] The value specified by mutex is invalid.
pthread_mutex_trylock() may fail if:
[EBUSY] Mutex is already locked.
[EINVAL] The value specified by mutex is invalid.
pthread_mutex_unlock() may fail if:
[EINVAL] The value specified by mutex is invalid.
[EPERM] The current thread does not hold a lock on mutex.
SEE ALSO pthread(3), pthread_barrier(3), pthread_cond(3), pthread_mutexattr(3), pthread_rwlock(3), pthread_spin(3)STANDARDS
These functions conform to IEEE Std 1003.1-2001 (``POSIX.1'').
BSD July 8, 2010 BSD