Che materia stai cercando?

Sistemi operativi - Syscall pthread_mutex_lock Appunti scolastici Premium

Appunti di sistemi operativi per l'esame dei professori Cotroneo e Natella. gli argomenti trattati sono i seguenti: System call pthread_mutex_lock: name, sypnosis, description, return value, errors, examples, application usage, future directions, see also, derivation.

Esame di Sistemi operativi docente Prof. D. Cotroneo

Anteprima

ESTRATTO DOCUMENTO

pthread_mutex_lock http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_mutex_...

The Single UNIX ® Specification, Version 2

Copyright © 1997 The Open Group

NAME

pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_unlock - lock and unlock a

mutex

SYNOPSIS

#include <pthread.h>

int pthread_mutex_lock(pthread_mutex_t *mutex);

int pthread_mutex_trylock(pthread_mutex_t *mutex);

int pthread_mutex_unlock(pthread_mutex_t *mutex);

DESCRIPTION

The mutex object referenced by mutex is locked by calling pthread_mutex_lock(). If the

mutex is already locked, the calling thread blocks until the mutex becomes available. This

operation returns with the mutex object referenced by mutex in the locked state with the

calling thread as its owner.

If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection is not provided.

Attempting to relock the mutex causes deadlock. If a thread attempts to unlock a mutex that

it has not locked or a mutex which is unlocked, undefined behaviour results.

If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking is provided.

If a thread attempts to relock a mutex that it has already locked, an error will be returned. If a

thread attempts to unlock a mutex that it has not locked or a mutex which is unlocked, an

error will be returned.

If the mutex type is PTHREAD_MUTEX_RECURSIVE, then the mutex maintains the

concept of a lock count. When a thread successfully acquires a mutex for the first time, the

lock count is set to one. Every time a thread relocks this mutex, the lock count is incremented

by one. Each time the thread unlocks the mutex, the lock count is decremented by one. When

the lock count reaches zero, the mutex becomes available for other threads to acquire. If a

thread attempts to unlock a mutex that it has not locked or a mutex which is unlocked, an

error will be returned.

If the mutex type is PTHREAD_MUTEX_DEFAULT, attempting to recursively lock the

mutex results in undefined behaviour. Attempting to unlock the mutex if it was not locked by

the calling thread results in undefined behaviour. Attempting to unlock the mutex if it is not

locked results in undefined behaviour.

The function pthread_mutex_trylock() is identical to pthread_mutex_lock() except that if the

mutex object referenced by mutex is currently locked (by any thread, including the current

thread), the call returns immediately.

The pthread_mutex_unlock() function releases the mutex object referenced by mutex. The

manner in which a mutex is released is dependent upon the mutex's type attribute. If there are

threads blocked on the mutex object referenced by mutex when pthread_mutex_unlock() is

called, resulting in the mutex becoming available, the scheduling policy is used to determine

1 di 3 10/06/2010 16:27


PAGINE

3

PESO

92.00 KB

AUTORE

N. A.

PUBBLICATO

+1 anno fa


DETTAGLI
Corso di laurea: Corso di laurea in ingegneria informatica
SSD:
A.A.: 2013-2014

I contenuti di questa pagina costituiscono rielaborazioni personali del Publisher N. A. di informazioni apprese con la frequenza delle lezioni di Sistemi operativi e studio autonomo di eventuali libri di riferimento in preparazione dell'esame finale o della tesi. Non devono intendersi come materiale ufficiale dell'università Napoli Federico II - Unina o del prof Cotroneo Domenico.

Acquista con carta o conto PayPal

Scarica il file tutte le volte che vuoi

Paga con un conto PayPal per usufruire della garanzia Soddisfatto o rimborsato

Recensioni
Ti è piaciuto questo appunto? Valutalo!

Altri appunti di Sistemi operativi

Sistemi Operativi
Dispensa
Sistemi Operativi
Dispensa
Sistemi operativi - schema suntivo per la prova pratica
Appunto
Tesine sui sistemi operativi
Appunto