Lines Matching +full:protect +full:- +full:exec

16 .\" Standard for Information Technology -- Portable Operating System
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
51 mutex_destroy \- mutual exclusion locks
55 cc -mt [ \fIflag\fR... ] \fIfile\fR... [ \fIlibrary\fR... ]
104 Mutexes are either intra-process or inter-process, depending upon the argument
111 For inter-process synchronization, a mutex needs to be allocated in memory
148 The \fItype\fR argument can be augmented by the bitwise-inclusive-\fBOR\fR of
287 Default mutex initialization (intra-process):
308 Customized mutex initialization (inter-process):
318 Customized mutex initialization (inter-process robust):
363 call to unlock the mutex to protect it from simultaneous access by multiple
365 the critical section of code that is enclosed by the mutex-locking call and the
366 mutex-unlocking call, whether the mutex's scope is intra-process or
367 inter-process. A thread calling to lock the mutex either gets exclusive access
479 non-\fBLOCK_RECURSIVE\fR mutex if:
491 The \fBmutex_lock()\fR function may fail for a non-\fBLOCK_ERRORCHECK\fR and
492 non-\fBLOCK_RECURSIVE\fR mutex if:
568 The following example uses one global mutex as a gate-keeper to permit each
569 thread exclusive sequential access to the code within the user-defined
570 function "change_global_data." This type of synchronization will protect the
575 /* cc thisfile.c -lthread */
606 many functions that use just one mutex to protect one data:
610 /* CC thisfile.c -lthread use C++ to compile*/
642 Global_data--;
658 if ((switcher++ % 3) == 0) /* one-in-three threads subtracts */
669 A mutex can protect data that is shared among processes. The mutex would need
671 process-shared mutex and writes it to a file to be mapped into memory by all
674 mutex-protected data.
678 /* cc thisfile.c -lthread */
688 #define INTERPROCESS_FILE "ipc-sharedfile"
710 /* Initializes the process-shared mutex */
716 buffer->Interprocess_data = 0;
717 mutex_init(&buffer->Interprocess_mutex, USYNC_PROCESS,0);
725 while(ipc_fd = open(INTERPROCESS_FILE, O_RDWR)) == -1)
739 mutex_lock(&buffer->Interprocess_mutex);
740 buffer->Interprocess_data++;
742 printf("%d is add-interprocess data, and %c is argv1\en",
743 buffer->Interprocess_data, argv_1[0]);
744 mutex_unlock(&buffer->Interprocess_mutex);
749 mutex_lock(&buffer->Interprocess_mutex);
750 buffer->Interprocess_data--;
752 printf("%d is subtract-interprocess data, and %c is argv1\en",
753 buffer->Interprocess_data, argv_1[0]);
754 mutex_unlock(&buffer->Interprocess_mutex);
781 A mutex can protect data that is shared among processes robustly. The mutex
783 process initializes the robust process-shared mutex and writes it to a file to
786 concurrently or not) and share mutex-protected data.
794 /* cc thisfile.c -lthread */
801 #define INTERPROCESS_FILE "ipc-sharedfile"
814 while((ipc_fd = open(INTERPROCESS_FILE, O_RDWR)) == -1)
818 mutex_init(&buffer->Interprocess_mutex,
825 buffer->Interprocess_data = 0;
826 mutex_init(&buffer->Interprocess_mutex,
830 rc = mutex_lock(&buffer->Interprocess_mutex);
841 mutex_consistent(&buffer->Interprocess_mutex);
842 mutex_unlock(&buffer->Interprocess_mutex);
854 * There is no error - data is consistent.
857 mutex_unlock(&buffer->Interprocess_mutex);
875 buffer->Interprocess_data = 0;
893 mutex_init(&r->m, USYNC_THREAD, NULL);
910 mutex_lock(&r->m); mutex_lock(&r->m);
911 r->field1++; localvar = r->field1;
912 mutex_unlock(&r->m); mutex_unlock(&r->m);
931 mutex_destroy(&r->m); /* first destroy mutex */
953 MT-Level MT-Safe
984 performed one of the \fBexec\fR(2) functions. The \fBELOCKUNMAPPED\fR error