Example #1
0
File: 1-1.c Project: 1587/ltp
int main(void)
{

	/* Make sure there is prioceiling capability. */
	/* #ifndef _POSIX_PRIORITY_SCHEDULING
	   fprintf(stderr,"prioceiling attribute is not available for testing\n");
	   return PTS_UNRESOLVED;
	   #endif */

	pthread_mutexattr_t ma;
	int prioceiling, max_prio, min_prio, ret;

	/* Initialize a mutex attributes object */
	ret = pthread_mutexattr_init(&ma);
	if (ret != 0) {
		print_pthread_error("pthread_mutexattr_init", ret);
		return PTS_UNRESOLVED;
	}

	ret = pthread_mutexattr_setprotocol(&ma, PTHREAD_PRIO_PROTECT);
	if (ret != 0) {
		print_pthread_error("pthread_mutexattr_protocol", ret);
		return PTS_UNRESOLVED;
	}

	/* Get the prioceiling mutex attr. */
	ret = pthread_mutexattr_getprioceiling(&ma, &prioceiling);
	if (ret != 0) {
		print_pthread_error("pthread_mutexattr_getprioceiling", ret);
		return PTS_UNRESOLVED;
	}

	/* Get the max and min according to SCHED_FIFO */
	max_prio = sched_get_priority_max(SCHED_FIFO);
	min_prio = sched_get_priority_min(SCHED_FIFO);

	/* Ensure that prioceiling is within legal limits. */
	if ((prioceiling < min_prio) || (prioceiling > max_prio)) {
		printf
		    ("Test FAILED: Default prioceiling %d is not compliant with SCHED_FIFO boundary.\n",
		     prioceiling);
		return PTS_FAIL;
	}

	printf("Test PASSED: Prioceiling %d\n", prioceiling);
	return PTS_PASS;
}
SkMutex::SkMutex() {
    if (sizeof(pthread_mutex_t) > sizeof(fStorage)) {
        SkDEBUGF(("pthread mutex size = %d\n", sizeof(pthread_mutex_t)));
        SkDEBUGFAIL("mutex storage is too small");
    }

    int status;
    pthread_mutexattr_t attr;

    status = pthread_mutexattr_init(&attr);
    print_pthread_error(status);
    SkASSERT(0 == status);

    status = pthread_mutex_init((pthread_mutex_t*)fStorage, &attr);
    print_pthread_error(status);
    SkASSERT(0 == status);
}
Example #3
0
SkMutex::~SkMutex() {
    int status = pthread_mutex_destroy(&fMutex);

    // only report errors on non-global mutexes
    if (status != 0) {
        print_pthread_error(status);
        SkASSERT(0 == status);
    }
}
SkMutex::SkMutex() {
    int status;

    status = pthread_mutex_init(&fMutex, NULL);
    if (status != 0) {
        print_pthread_error(status);
        SkASSERT(0 == status);
    }
}
Example #5
0
SkMutex::~SkMutex() {
    int status = pthread_mutex_destroy((pthread_mutex_t*)fStorage);
#if 0
    // only report errors on non-global mutexes
    if (!fIsGlobal) {
        print_pthread_error(status);
        SkASSERT(0 == status);
    }
#endif
}
Example #6
0
SkMutex::SkMutex(bool global)
    : fIsGlobal(global)
{
    int status;

    status = pthread_mutex_init(&fMutex, NULL);
    if (status != 0) {
        print_pthread_error(status);
        SkASSERT(0 == status);
    }
}
Example #7
0
void SkMutex::release() {
    int status = pthread_mutex_unlock((pthread_mutex_t*)fStorage);
    print_pthread_error(status);
    SkASSERT(0 == status);
}
Example #8
0
void SkMutex::acquire() {
    int status = pthread_mutex_lock((pthread_mutex_t*)fStorage);
    print_pthread_error(status);
    SkASSERT(0 == status);
}