-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IE][VPU][XLink]: XLink semaphore wrappers impl (#3079)
XLink wrappers for POSIX semaphore functions (refer sem_overview for details). In the description of standard sem_destroy the following is noted: "Destroying a semaphore that other processes or threads are currently blocked on (in sem_wait(3)) produces undefined behavior." XLink wrappers use thread-safe reference count and destroy the semaphore only in case if there are no waiters. * XLink semaphore wrapper impl * Extend XLink win_synchapi
- Loading branch information
1 parent
fec3bc0
commit 2a7f2f5
Showing
11 changed files
with
290 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
inference-engine/thirdparty/movidius/XLink/shared/include/XLinkSemaphore.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (C) 2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
/// | ||
/// @file | ||
/// | ||
/// @brief Application configuration Leon header | ||
/// | ||
|
||
#ifndef _XLINKSEMAPHORE_H | ||
#define _XLINKSEMAPHORE_H | ||
|
||
# if (defined(_WIN32) || defined(_WIN64)) | ||
# include "win_pthread.h" | ||
# include "win_semaphore.h" | ||
# include "win_synchapi.h" | ||
# else | ||
# include <pthread.h> | ||
# ifdef __APPLE__ | ||
# include "pthread_semaphore.h" | ||
# else | ||
# include <semaphore.h> | ||
# endif | ||
# endif | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
// | ||
// This structure describes the semaphore used in XLink and | ||
// extends the standard semaphore with a reference count. | ||
// The counter is thread-safe and changes only in cases if | ||
// all tools of thread synchronization are really unlocked. | ||
// refs == -1 in case if semaphore was destroyed; | ||
// refs == 0 in case if semaphore was initialized but has no waiters; | ||
// refs == N in case if there are N waiters which called sem_wait(). | ||
// | ||
|
||
typedef struct { | ||
sem_t psem; | ||
int refs; | ||
} XLink_sem_t; | ||
|
||
// | ||
// XLink wrappers for POSIX semaphore functions (refer sem_overview for details) | ||
// In description of standard sem_destroy the following can be noted: | ||
// "Destroying a semaphore that other processes or threads are currently | ||
// blocked on (in sem_wait(3)) produces undefined behavior." | ||
// XLink wrappers use thread-safe reference count and destroy the semaphore only in case | ||
// if there are no waiters | ||
// | ||
|
||
int XLink_sem_init(XLink_sem_t* sem, int pshared, unsigned int value); | ||
int XLink_sem_destroy(XLink_sem_t* sem); | ||
int XLink_sem_post(XLink_sem_t* sem); | ||
int XLink_sem_wait(XLink_sem_t* sem); | ||
int XLink_sem_timedwait(XLink_sem_t* sem, const struct timespec* abstime); | ||
|
||
// | ||
// Helper functions for XLink semaphore wrappers. | ||
// Use them only in case if you know what you are doing. | ||
// | ||
|
||
int XLink_sem_set_refs(XLink_sem_t* sem, int refs); | ||
int XLink_sem_get_refs(XLink_sem_t* sem, int *sval); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // _XLINKSEMAPHORE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.