|
|
|
@ -2599,6 +2599,25 @@ int _cgsem_mswait(cgsem_t *cgsem, int ms, const char *file, const char *func, co
@@ -2599,6 +2599,25 @@ int _cgsem_mswait(cgsem_t *cgsem, int ms, const char *file, const char *func, co
|
|
|
|
|
/* We don't reach here */ |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Reset semaphore count back to zero */ |
|
|
|
|
void cgsem_reset(cgsem_t *cgsem) |
|
|
|
|
{ |
|
|
|
|
int ret, fd; |
|
|
|
|
fd_set rd; |
|
|
|
|
char buf; |
|
|
|
|
|
|
|
|
|
fd = cgsem->pipefd[0]; |
|
|
|
|
FD_ZERO(&rd); |
|
|
|
|
FD_SET(fd, &rd); |
|
|
|
|
do { |
|
|
|
|
struct timeval timeout = {0, 0}; |
|
|
|
|
|
|
|
|
|
ret = select(fd + 1, &rd, NULL, NULL, &timeout); |
|
|
|
|
if (ret > 0) |
|
|
|
|
ret = read(fd, &buf, 1); |
|
|
|
|
} while (ret > 0); |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
void _cgsem_init(cgsem_t *cgsem, const char *file, const char *func, const int line) |
|
|
|
|
{ |
|
|
|
@ -2639,6 +2658,15 @@ int _cgsem_mswait(cgsem_t *cgsem, int ms, const char *file, const char *func, co
@@ -2639,6 +2658,15 @@ int _cgsem_mswait(cgsem_t *cgsem, int ms, const char *file, const char *func, co
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cgsem_reset(cgsem_t *cgsem) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
ret = sem_trywait(cgsem); |
|
|
|
|
} while (!ret); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cgsem_destroy(cgsem_t *cgsem) |
|
|
|
|
{ |
|
|
|
|
sem_destroy(cgsem); |
|
|
|
|