kernel: Add posix API for semaphore
Add semaphore posix APIs. Signed-off-by: Punit Vara <punit.vara@intel.com>
This commit is contained in:
parent
b9588d8eb6
commit
a74725f1d3
7 changed files with 210 additions and 1 deletions
|
@ -157,7 +157,6 @@ static inline int pthread_condattr_destroy(pthread_condattr_t *att)
|
|||
.sem = &name##_psem, \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief POSIX threading compatibility API
|
||||
*
|
||||
|
|
28
include/posix/semaphore.h
Normal file
28
include/posix/semaphore.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _POSIX_SEMAPHORE_H
|
||||
#define _POSIX_SEMAPHORE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sys/types.h"
|
||||
#include <time.h>
|
||||
|
||||
int sem_destroy(sem_t *semaphore);
|
||||
int sem_getvalue(sem_t *semaphore, int *value);
|
||||
int sem_init(sem_t *semaphore, int pshared, unsigned int value);
|
||||
int sem_post(sem_t *semaphore);
|
||||
int sem_timedwait(sem_t *semaphore, struct timespec *abstime);
|
||||
int sem_trywait(sem_t *semaphore);
|
||||
int sem_wait(sem_t *semaphore);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* POSIX_SEMAPHORE_H */
|
|
@ -30,6 +30,9 @@ typedef struct pthread_attr_t {
|
|||
|
||||
typedef void *pthread_t;
|
||||
|
||||
/* Semaphore */
|
||||
typedef struct k_sem sem_t;
|
||||
|
||||
/* Mutex */
|
||||
typedef struct pthread_mutex {
|
||||
struct k_sem *sem;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue