Changeset d600e18 in git
- Timestamp:
- Nov 5, 2013, 12:51:24 PM (10 years ago)
- Branches:
- (u'spielwiese', 'd1b01e9d51ade4b46b745d3bada5c5f3696be3a8')
- Children:
- 2fa80a36c041e00aa30582d92c55f22cc3fe47d8
- Parents:
- 659a7af613781bb070ab2564b6aff1c52a070df4
- git-author:
- Andreas Steenpass <steenpass@mathematik.uni-kl.de>2013-11-05 12:51:24+01:00
- git-committer:
- Andreas Steenpass <steenpass@mathematik.uni-kl.de>2013-11-06 13:33:11+01:00
- Location:
- Singular
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/links/semaphore.c
r659a7a rd600e18 9 9 # include "simpleipc.h" 10 10 11 #include <Singular/cntrlc.h> 11 12 #include <Singular/si_signals.h> 12 13 … … 23 24 // but are supported more widely. 24 25 25 static sem_t *semaphore[SIPC_MAX_SEMAPHORES]; 26 sem_t *semaphore[SIPC_MAX_SEMAPHORES]; 27 int sem_acquired[SIPC_MAX_SEMAPHORES]; 26 28 27 29 /* return 1 on success, … … 74 76 { 75 77 if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL)) return -1; 78 defer_shutdown++; 76 79 si_sem_wait(semaphore[id]); 80 sem_acquired[id]++; 81 defer_shutdown--; 82 if (!defer_shutdown && do_shutdown) m2_end(1); 77 83 return 1; 78 84 } … … 81 87 { 82 88 if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL)) return -1; 83 return !si_sem_trywait(semaphore[id]); 89 defer_shutdown++; 90 int trywait = si_sem_trywait(semaphore[id]); 91 if (!trywait) 92 { 93 sem_acquired[id]++; 94 } 95 defer_shutdown--; 96 if (!defer_shutdown && do_shutdown) m2_end(1); 97 return !trywait; 84 98 } 85 99 … … 87 101 { 88 102 if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL)) return -1; 103 defer_shutdown++; 89 104 sem_post(semaphore[id]); 105 sem_acquired[id]--; 106 defer_shutdown--; 107 if (!defer_shutdown && do_shutdown) m2_end(1); 90 108 return 1; 91 109 } -
Singular/links/simpleipc.h
r659a7a rd600e18 1 #include <semaphore.h> 2 1 3 #ifndef _SIMPLEIPC_H 2 4 #define _SIMPLEIPC_H … … 9 11 10 12 #define USE_SEM_INIT 0 13 14 extern sem_t *semaphore[SIPC_MAX_SEMAPHORES]; 15 extern int sem_acquired[SIPC_MAX_SEMAPHORES]; 11 16 12 17 int sipc_semaphore_init(int id, int count); -
Singular/links/ssiLink.cc
r659a7a rd600e18 805 805 } 806 806 ssiToBeClosed->next=NULL; 807 #ifdef HAVE_SIMPLEIPC 808 memset(sem_acquired, 0, SIPC_MAX_SEMAPHORES*sizeof(sem_acquired[0])); 809 #endif // HAVE_SIMPLEIPC 807 810 si_close(pc[1]); si_close(cp[0]); 808 811 d->f_write=fdopen(cp[1],"w"); -
Singular/misc_ip.cc
r659a7a rd600e18 23 23 #define SI_DONT_HAVE_GLOBAL_VARS 24 24 #include <factory/factory.h> 25 #endif 26 27 #ifdef HAVE_SIMPLEIPC 28 #include <Singular/links/simpleipc.h> 25 29 #endif 26 30 … … 1055 1059 { 1056 1060 m2_end_called = TRUE; 1061 #ifdef HAVE_SIMPLEIPC 1062 for (int i = SIPC_MAX_SEMAPHORES; i >= 0; i--) 1063 { 1064 if (semaphore[i] != NULL) 1065 { 1066 while (sem_acquired[i] > 0) 1067 { 1068 sem_post(semaphore[i]); 1069 sem_acquired[i]--; 1070 } 1071 } 1072 } 1073 #endif // HAVE_SIMPLEIPC 1057 1074 fe_reset_input_mode(); 1058 1075 #ifdef PAGE_TEST
Note: See TracChangeset
for help on using the changeset viewer.