Changeset 1646
- Timestamp:
- Nov 17, 2004, 10:12:37 AM (21 years ago)
- Location:
- trunk/src/emx/src/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.79
to1.80
r1645 r1646 1267 1267 "__std_wait4" @1289 1268 1268 "__std_getopt_long_only" @1290 1269 "___libc_Back_signalTimer" @1291 1270 "__std_getitimer" @1292 1271 "__std_setitimer" @1293 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/getitimer.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1645 r1646 46 46 * @param pValue Where to store the value. 47 47 */ 48 int getitimer(int iWhich, struct itimerval *pValue)48 int _STD(getitimer)(int iWhich, struct itimerval *pValue) 49 49 { 50 50 LIBCLOG_ENTER("iWhich=%d pValue=%p\n", iWhich, (void *)pValue); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_signal.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1645 r1646 61 61 int __libc_back_signalInheritPack(__LIBC_PSPMINHSIG *ppSig, size_t *pcbSig); 62 62 void __libc_back_signalTimerNotifyTerm(void); 63 int __libc_back_signalRaiseInternal(__LIBC_PTHREAD pThrd, int iSignalNo, const siginfo_t *pSigInfo, void *pvQueued, unsigned fFlags); 63 64 64 65 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_signalTimer.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1645 r1646 32 32 #define INCL_BASE 33 33 #define INCL_FSMACROS 34 #define INCL_DOSINFOSEG 34 35 #define INCL_ERRORS 35 36 #include <os2emx.h> … … 82 83 83 84 /* 85 * Gather stuff we need. 86 */ 87 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 88 LIBC_ASSERT(pThrd && pThrd->fInternalThread); 89 GINFOSEG volatile *pGIS = GETGINFOSEG(); 90 LIBC_ASSERT(pGIS && pGIS->uchMajorVersion); 91 PPIB pPib = NULL; 92 PTIB pTib = NULL; 93 int rc = DosGetInfoBlocks(&pTib, &pPib); 94 LIBC_ASSERTM(rc == 0 && pPib && pPib->pib_ulpid && pTib && pTib->tib_ptib2->tib2_ultid, "DosGetInfoBlocks -> %d\n", rc); 95 96 /* 84 97 * Change the priority to TC to make the timer more accurate. 85 98 */ 86 intrc = DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);99 rc = DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); 87 100 LIBC_ASSERTM(rc == 0, "DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0) -> %d\n", rc); 88 101 … … 104 117 break; 105 118 } 119 if (pPib->pib_flstatus & (0x40/*dying*/ | 0x04/*exiting all*/ | 0x02/*Exiting Thread 1*/ | 0x01/*ExitList */)) 120 { 121 LIBCLOG_MSG("Timer worker stopping: pPib->pib_flstatus=%#02lx\n", pPib->pib_flstatus); 122 break; 123 } 106 124 107 125 /* 108 126 * Calc next. 109 127 */ 110 if (guInterval) 111 __atomic_xchg(&guNext, signalTimerClock() + guInterval); 112 113 /* 114 * Re-arm timer. 115 */ 116 int fArmed = gfArmed; 117 if (gfOneShot) 118 { 119 __libc_back_signalSemRequest(); 120 if (gfOneShot && gfArmed) 128 unsigned uTime = pGIS->msecs; 129 130 /* 131 * Take the semaphore. 132 * Recheck for termination afterwards. 133 */ 134 int rc = __libc_back_signalSemRequest(); 135 if (rc) 136 { 137 LIBCLOG_MSG("Timer worker stopping: __libc_back_signalSemRequest() -> %d\n", rc); 138 break; 139 } 140 if (gfTerminate) 141 { 142 __libc_back_signalSemRelease(); 143 LIBCLOG_MSG("Timer worker stopping: gfTerminate=%d\n", gfTerminate); 144 break; 145 } 146 if (pPib->pib_flstatus & (0x40/*dying*/ | 0x04/*exiting all*/ | 0x02/*Exiting Thread 1*/ | 0x01/*ExitList */)) 147 { 148 __libc_back_signalSemRelease(); 149 LIBCLOG_MSG("Timer worker stopping: pPib->pib_flstatus=%#02lx\n", pPib->pib_flstatus); 150 break; 151 } 152 153 154 /* 155 * Update guNext and if needed rearm the timer. 156 */ 157 if (gfArmed) 158 { 159 if (!gfOneShot) 160 __atomic_xchg(&guNext, uTime + guInterval); 161 else 121 162 { 122 163 __atomic_xchg(&gfOneShot, 0); … … 124 165 if (guInterval) 125 166 { 126 __atomic_xchg(&guNext, signalTimerClock() + guInterval + 1); 167 /* 168 * Start a new timer. 169 * Note that we've not compensated for any delays, thus the 2nd SIGALRM may 170 * be a little bit later than the others. Should matter that much I hope... 171 */ 172 __atomic_xchg(&guNext, pGIS->msecs + guInterval + 1); 127 173 rc = DosStartTimer(guInterval, (HSEM)ghevTimer, (PHTIMER)&ghTimer); 128 174 if (rc) 175 { 176 LIBC_ASSERTM_FAILED("DosStartTimer(%d,,) -> rc=%d\n", guInterval, rc); 129 177 __atomic_xchg(&gfArmed, 0); 178 } 130 179 } 180 /* 181 * It was a one shot setup, we're done. 182 */ 131 183 else 132 184 __atomic_xchg(&gfArmed, 0); 133 185 } 134 186 135 __libc_back_signalSemRelease(); 136 } 137 138 /* 139 * Raise a SIGALRM. 140 */ 141 if (fArmed) 142 { 143 rc = __libc_Back_signalRaise(SIGALRM, &SigInfo, NULL, 0); 187 /* 188 * Raise SIGALRM. 189 */ 190 rc = __libc_back_signalRaiseInternal(pThrd, SIGALRM, &SigInfo, NULL, 0); 144 191 if (rc < 0) 145 LIBCLOG_MSG("__libc_Back_signalRaise -> %d\n", rc); 146 } 192 LIBCLOG_MSG("__libc_back_signalRaiseInternal -> %d\n", rc); 193 } 194 195 /* 196 * Done with the semaphore. 197 */ 198 __libc_back_signalSemRelease(); 147 199 148 200 /* … … 158 210 if (cCount > 1) 159 211 LIBCLOG_MSG("cCount=%ld missed=%ld shots!\n", cCount, cCount - 1); 160 } 212 } /* loop forever */ 161 213 162 214 /* -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/signals.c
-
Property cvs2svn:cvs-rev
changed from
1.14
to1.15
r1645 r1646 961 961 { 962 962 LIBC_ASSERTM_FAILED("Invalid signal %d\n", iSignalNo); 963 return -EINVAL;963 LIBCLOG_RETURN_INT(-EINVAL); 964 964 } 965 965 … … 974 974 { 975 975 LIBC_ASSERTM_FAILED("No thread structure and we cannot safely create one!\n"); 976 return __LIBC_BSRR_PASSITON | (__SIGSET_ISSET(&__libc_gSignalRestartMask, iSignalNo) ? __LIBC_BSRR_RESTART : __LIBC_BSRR_INTERRUPT); 976 int rc = __LIBC_BSRR_PASSITON | (__SIGSET_ISSET(&__libc_gSignalRestartMask, iSignalNo) ? __LIBC_BSRR_RESTART : __LIBC_BSRR_INTERRUPT); 977 LIBCLOG_RETURN_INT(rc); 977 978 } 978 979 pThrd = __libc_threadCurrent(); … … 980 981 { 981 982 LIBC_ASSERTM_FAILED("Failed to get thread structure!\n"); 982 return -ENOMEM;983 LIBCLOG_RETURN_INT(-ENOMEM); 983 984 } 984 985 } … … 1037 1038 return rc; 1038 1039 } 1040 1041 1042 /** 1043 * Schedules a signal generated by an internal worker thread. 1044 * 1045 * @returns 0 on success. 1046 * @returns On failure a negative error code (errno.h) is returned. 1047 * @param pThrd The current thread. 1048 * @param iSignalNo Signal to raise. 1049 * @param pSigInfo Pointer to signal info for this signal. 1050 * NULL is allowed. 1051 * @param pvQueued If __LIBC_BSRF_QUEUED is set, can optionally point to 1052 * locally malloced SIGQUEUED node. 1053 * @param fFlags Flags of the #defines __LIBC_BSRF_* describing how to 1054 * deliver the signal. 1055 */ 1056 int __libc_back_signalRaiseInternal(__LIBC_PTHREAD pThrd, int iSignalNo, const siginfo_t *pSigInfo, void *pvQueued, unsigned fFlags) 1057 { 1058 LIBCLOG_ENTER("pThrd=%p{.tid=%#x} iSignalNo=%d pSigInfo=%p{.si_signo=%d, .si_errno=%d, .si_code=%#x, .si_timestamp=%#x, .si_flags=%#x .si_pid=%#x, .si_pgrp=%#x, .si_tid=%#x, .si_uid=%d, .si_status=%d, .si_addr=%p, .si_value=%p, .si_band=%ld, .si_fd=%d} pvQueued=%p fFlags=%#x\n", 1059 (void *)pThrd, pThrd->tid, 1060 iSignalNo, (void *)pSigInfo, 1061 pSigInfo ? pSigInfo->si_signo : 0, 1062 pSigInfo ? pSigInfo->si_errno : 0, 1063 pSigInfo ? pSigInfo->si_code : 0, 1064 pSigInfo ? pSigInfo->si_timestamp : 0, 1065 pSigInfo ? pSigInfo->si_flags : 0, 1066 pSigInfo ? pSigInfo->si_pid : 0, 1067 pSigInfo ? pSigInfo->si_pgrp : 0, 1068 pSigInfo ? pSigInfo->si_tid : 0, 1069 pSigInfo ? pSigInfo->si_uid : 0, 1070 pSigInfo ? pSigInfo->si_status : 0, 1071 pSigInfo ? pSigInfo->si_addr : 0, 1072 pSigInfo ? pSigInfo->si_value.sigval_ptr : 0, 1073 pSigInfo ? pSigInfo->si_band : 0, 1074 pSigInfo ? pSigInfo->si_fd : 0, 1075 (void *)pvQueued, fFlags); 1076 1077 /* 1078 * Can't be to careful! 1079 */ 1080 LIBC_ASSERT(__libc_back_signalSemIsOwner()); 1081 LIBC_ASSERT(pThrd->fInternalThread); 1082 if (!__SIGSET_SIG_VALID(iSignalNo) || iSignalNo == 0) 1083 { 1084 LIBC_ASSERTM_FAILED("Invalid signal %d\n", iSignalNo); 1085 LIBCLOG_RETURN_INT(-EINVAL); 1086 } 1087 1088 /* 1089 * Copy the siginfo structure and fill in the rest of 1090 * the SigInfo packet (if we've got one). 1091 */ 1092 siginfo_t SigInfo; 1093 SigInfo = *pSigInfo; 1094 if (!SigInfo.si_timestamp) 1095 SigInfo.si_timestamp = signalTimestamp(); 1096 if (fFlags & __LIBC_BSRF_QUEUED) 1097 SigInfo.si_flags |= __LIBC_SI_QUEUED; 1098 if (!SigInfo.si_pid) 1099 SigInfo.si_pid = _sys_pid; 1100 if (!SigInfo.si_tid) 1101 SigInfo.si_tid = pThrd->tid; 1102 1103 /* 1104 * Schedule the signal. 1105 */ 1106 int rc = signalSchedule(pThrd, iSignalNo, &SigInfo, fFlags, fFlags & __LIBC_BSRF_QUEUED ? pvQueued : NULL); 1107 1108 LIBCLOG_RETURN_INT(rc); 1109 } 1110 1039 1111 1040 1112 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.