Changeset 1461
- Timestamp:
- Sep 6, 2004, 6:22:46 AM (21 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/Makefile
-
Property cvs2svn:cvs-rev
changed from
1.48
to1.49
r1460 r1461 200 200 # must use the shell. 201 201 EMXOMF = $(call GETTOOL2,emxomf) 202 DO.EMXOMF = $(EMXOMF) $(strip $1 -o) $@ $(if $<,$<, $(subst /omf /,/aout/,$(@:.obj=.o)) )202 DO.EMXOMF = $(EMXOMF) $(strip $1 -o) $@ $(if $<,$<, $(subst /omf-prof/,/aout-prof/,$(subst /omf-log/,/aout-log/,$(subst /omf/,/aout/,$(@:.obj=.o)))) ) 203 203 204 204 # How to copy some file to installation directory … … 343 343 @$(call ECHO,smak don't generate rules anylonger!) 344 344 345 # The general a.out -> OMF conversion rule for object files345 # The general a.out -> OMF conversion rules for object files 346 346 $.omf/%.obj: 347 $(call DO.EMXOMF) 348 $.omf-log/%.obj: 349 $(call DO.EMXOMF) 350 $.omf-prof/%.obj: 347 351 $(call DO.EMXOMF) 348 352 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/InnoTekLIBC/fork.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1460 r1461 494 494 /* Priority of this callback */ 495 495 unsigned uPriority; 496 /** Pointer to the next record in a sorted callback list. 497 * @remark This is initialized to point to self in order to shut up the compiler. 498 * (Encountered some limitations of the GNU inline assmebler which prevents me from 499 * referencing the symbol.) 500 */ 501 struct __libc_ForkCallback *pNext; 496 /** Pointer to self. 497 * This is a hack to allow the callbacks to be static without gcc 498 * optimizing them away as unused. 499 */ 500 const struct __libc_ForkCallback *pSelf; 502 501 } __LIBC_FORKCALLBACK, *__LIBC_PFORKCALLBACK; 503 502 … … 513 512 */ 514 513 #define _FORK_PARENT1(uPriority, pfnCallback) \ 515 static __LIBC_FORKCALLBACK __fork_parent1_##pfnCallback = { pfnCallback, uPriority, &__fork_parent1_##pfnCallback }; \514 static const __LIBC_FORKCALLBACK __fork_parent1_##pfnCallback = { pfnCallback, uPriority, &__fork_parent1_##pfnCallback }; \ 516 515 __asm__ (".stabs \"___fork_parent1__\", 25, 0, 0, ___fork_parent1_" #pfnCallback); 517 516 … … 526 525 */ 527 526 #define _FORK_CHILD1(uPriority, pfnCallback) \ 528 static __LIBC_FORKCALLBACK __fork_child1_##pfnCallback = { pfnCallback, uPriority, &__fork_child1_##pfnCallback }; \527 static const __LIBC_FORKCALLBACK __fork_child1_##pfnCallback = { pfnCallback, uPriority, &__fork_child1_##pfnCallback }; \ 529 528 __asm__ (".stabs \"___fork_child1__\", 25, 0, 0, ___fork_child1_" #pfnCallback ); 530 529 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/InnoTekLIBC/sharedpm.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1460 r1461 233 233 /** Pointer to fork handle which a child should use when spawned by fork(). */ 234 234 void *pvForkHandle; 235 /** Creation timestamp. */ 236 unsigned uTimestamp; 235 237 236 238 /** Reserved pool pointer field with default value 0. */ 237 unsigned aReserved[40 - 1 3];239 unsigned aReserved[40 - 14]; 238 240 239 241 /** Number of possible pointers to shared memory starting at pvInherit. … … 243 245 /** Pointer to data inherited from the parent process. */ 244 246 __LIBC_PSPMINHERIT volatile pInherit; 247 /** Pointer to data inherited from the parent process when it's locked. 248 * When locked pInherit is NULL and this member points to the data instead. 249 * This prevents spmAlloc() from reclaiming it while it's in use. */ 250 __LIBC_PSPMINHERIT volatile pInheritLocked; 245 251 } __LIBC_SPMPROCESS, *__LIBC_PSPMPROCESS; 246 252 … … 367 373 368 374 /** 375 * Gets the inherit data associated with the current process. 376 * This call prevents it from being release by underrun handling. 377 * 378 * @returns Pointer to inherit data. 379 * The caller must call __libc_spmInheritRelease() when done. 380 * @returns NULL and errno if no inherit data. 381 */ 382 __LIBC_PSPMINHERIT __libc_spmInheritRequest(void); 383 384 /** 385 * Releases the inherit data locked by the __libc_spmInheritRequest() call. 386 * 387 * @returns 0 on success. 388 * @returns -1 and errno on failure. 389 */ 390 int __libc_spmInheritRelease(void); 391 392 /** 393 * Frees the inherit data of this process. 394 * This is called when the executable is initialized. 395 */ 396 void __libc_spmInheritFree(void); 397 398 /** 369 399 * Create an embryo related to the current process. 370 400 * -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.60
to1.61
r1460 r1461 1118 1118 ; new stuff. 1119 1119 1120 "___libc_SpmCheck" @1140 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.smak
-
Property cvs2svn:cvs-rev
changed from
1.42
to1.43
r1460 r1461 57 57 LIBC.IMPLIB := $.omf/libc_dll.lib $.aout/libc_dll.a 58 58 LIBC.DEF := $.omf/libc.def 59 LIBC.OBJS := $.omf/src/lib/startup/dll0hifork.obj $.omf/src/lib/startup/dllinit.obj 59 LIBC.OBJS.COMMON := \ 60 $.omf/src/lib/sys/libcfork.obj \ 61 $.omf/src/lib/sys/sharedpm.obj \ 62 $.omf/src/lib/sys/__initdll.obj \ 63 $.omf/src/lib/malloc/_heapvoting.obj \ 64 $.omf/src/lib/process/fmutex.obj \ 65 $.omf/src/lib/sys/DosCreateEventSemEx.obj \ 66 $.omf/src/lib/sys/DosEx.obj \ 67 $.omf/src/lib/str/386/bzero.obj \ 68 $.omf/src/lib/sys/386/__init_environ.obj \ 69 $.omf/src/lib/malloc/_hmalloc.obj \ 70 $.omf/src/lib/malloc/_hinitheap.obj \ 71 $.omf/src/lib/sys/heaphigh.obj \ 72 $.omf/src/lib/sys/DosAllocMemEx.obj \ 73 $.omf/src/lib/malloc/ucreate2.obj \ 74 $.omf/src/lib/malloc/iaddmem.obj \ 75 $.omf/src/lib/malloc/imisc.obj \ 76 $.omf/src/lib/malloc/uopen.obj \ 77 $.omf/src/lib/sys/DosOpenEventSemEx.obj \ 78 $.omf/src/lib/malloc/umalloc.obj \ 79 $.omf/src/lib/malloc/ialloc.obj \ 80 $.omf/src/lib/sys/largefileio.obj \ 81 $.omf/src/lib/sys/filehandles.obj \ 82 $.omf/src/lib/malloc/_hcalloc.obj \ 83 $.omf/src/lib/malloc/ucalloc.obj \ 84 $.omf/src/lib/startup/dllinit.obj \ 85 $.omf/src/lib/startup/startup.obj \ 86 $.omf/src/lib/startup/ctor1.obj \ 87 $.omf/src/lib/sys/tcpipver.obj \ 88 $.omf/src/lib/sys/tcpipver43.obj \ 89 $.omf/src/lib/sys/pathrewrite.obj \ 90 $.omf/src/lib/app/getenv.obj \ 91 $.omf/src/lib/str/386/strlen.obj \ 92 $.omf/src/lib/str/strncmp.obj \ 93 $.omf/src/lib/app/stdio.obj \ 94 $.omf/src/lib/process/fmutex2.obj \ 95 $.omf/src/lib/io/_tmp.obj \ 96 $.omf/src/lib/process/thread_internals.obj \ 97 $.omf/src/lib/sys/b_threadInit.obj \ 98 $.omf/src/lib/malloc/malloc.obj \ 99 $.omf/src/lib/malloc/initr.obj \ 100 $.omf/src/lib/malloc/_linitheap.obj \ 101 $.omf/src/lib/sys/uflags.obj \ 102 $.omf/src/lib/sys/sbrk.obj \ 103 $.omf/src/lib/sys/heap.obj \ 104 $.omf/src/lib/sys/__init.obj 105 LIBC.OBJS := \ 106 $.omf/src/lib/startup/dll0hifork.obj \ 107 $(LIBC.OBJS.COMMON) 60 108 LIBC.LIBS := $.omf/libc_s.lib $.omf/libc_app.lib 61 109 LIBC.DEPS := $(LIBC.STUB) $.omf/libc_alias.lib … … 65 113 LIBC.PRF.DLL := $(LIBC.DLL:.dll=.prf) 66 114 LIBC.PRF.DEF := $.omf/libc.prf.def 67 LIBC.PRF.OBJS := $.omf/src/lib/startup/dll0hifork.obj $.omf-prof/src/lib/startup/dllinit.obj 115 LIBC.PRF.OBJS := \ 116 $.omf/src/lib/startup/dll0hifork.obj \ 117 $(subst /omf/,/omf-prof/,$(LIBC.OBJS.COMMON)) 68 118 LIBC.PRF.LIBS := $.omf-prof/libc_p_s.lib $.omf-prof/libc_app_p.lib 69 119 LIBC.PRF.DEPS := $(LIBC.DEPS) … … 72 122 LIBC.ELH.DLL := $(LIBC.DLL:.dll=.elh) 73 123 LIBC.ELH.DEF := $.omf/libc.elh.def 74 LIBC.ELH.OBJS := $(LIBC.OBJS) 124 LIBC.ELH.OBJS := \ 125 $.omf/src/lib/startup/dll0hifork.obj \ 126 $.omf/src/lib/startup/dllinit.obj 75 127 LIBC.ELH.LIBS := $(LIBC.LIBS) 76 128 LIBC.ELH.DEPS := $(LIBC.DEPS) … … 79 131 LIBC.LOG.DLL := $(LIBC.DLL:.dll=.logchk) 80 132 LIBC.LOG.DEF := $(LIBC.DEF) 81 LIBC.LOG.OBJS := $.omf/src/lib/startup/dll0hifork.obj $.omf/src/lib/startup/dllinit.obj 133 LIBC.LOG.OBJS := \ 134 $.omf/src/lib/startup/dll0hifork.obj \ 135 $(subst /omf/,/omf-log/,$(LIBC.OBJS.COMMON)) 82 136 LIBC.LOG.LIBS := $.omf-log/libc_l_s.lib $.omf-log/libc_app_l.lib 83 137 LIBC.LOG.DEPS := $(LIBC.DEPS) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/startup/startup.c
-
Property cvs2svn:cvs-rev
changed from
1.11
to1.12
r1460 r1461 55 55 * - dll0.s gets control and calls __init_dll in sys/__initdll.c 56 56 * - __init_dll calls __libc_HeapVote() to do the heap voting. 57 * - __init_dll calls __init_os_version() to set _osminor,_osmajor globals. 57 * - __init_dll initiates the _osminor and _osmajor globals. 58 * - __init_dll initiates _sys_gcbVirtualAddressLimit global. 58 59 * - __init_dll initiates _sys_pid and _sys_ppid globals. 59 * - __init_dll creates _sys_heap_fmutex and _sys_gmtxHimem.60 * - __init_dll creates _sys_heap_fmutex, _sys_gmtxHimem and __libc_gmtxExec. 60 61 * - __init_dll then initiates __libc_gpTLS with an allocated TLS ULONG. 61 62 * The thread structure it self isn't initialized untill it's actually 62 63 * referenced, and when it is there is static structure for the first 63 64 * thread needing its per thread area. 64 * - __init_dll calls __init_environ() which initializes environ and _org_environ. 65 * - __init_environ() will call _hmalloc() thus initiating the high heap. 65 * - __init_dll calls _sys_init_environ() which initializes environ and _org_environ. 66 * - _sys_init_environ() will call _hmalloc() thus initiating the high heap. 67 * - __init_dll calls __libc_spmSelf() which checks initiates SPM and gets 68 * any inherited properties. 66 69 * - __init_dll calls _sys_init_largefileio() which checks for LFN APIs. 67 * - __init_dll calls _ sys_init_filehandles() which initiates filehandle table.68 * - _ sys_init_filehandles() will call _hmalloc() and a number of OS/2 APIs70 * - __init_dll calls __libc_fhInit() which initiates filehandle table. 71 * - __libc_fhInit() will call _hmalloc() and a number of OS/2 APIs 69 72 * to figure out what handles was inherited. 70 73 * - __init_dll then intializes _sys_clock0_ms with the current MS count. … … 100 103 * - __init() parse the commandline creating argv and it's strings using the 101 104 * allocated stack space. 105 * - __init() calls __libc_spmInheritFree() to release the inherit data (shared) 106 * associated with the current process. 102 107 * - __init() installs the exception handler. 103 108 * - __init() set the signal focus. … … 112 117 * 113 118 * @todo update this with file handle changes! 119 * @todo update this with fork and performance changes! 114 120 */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__init.c
-
Property cvs2svn:cvs-rev
changed from
1.13
to1.14
r1460 r1461 26 26 #include <alloca.h> 27 27 #include <InnoTekLIBC/thread.h> 28 #include <InnoTekLIBC/sharedpm.h> 28 29 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_INITTERM 29 30 #include <InnoTekLIBC/logstrict.h> … … 214 215 215 216 /* 217 * Free the SPM inherit data. 218 */ 219 __libc_spmInheritFree(); 220 221 /* 216 222 * Install exception handler. 217 223 */ … … 442 448 { 443 449 __asm__ ("cld"); /* Don't trust */ 444 LIBCLOG_MSG2("!!! num %08lx flags %08lx nested %p whatever %p\n", report->ExceptionNum, report->fHandlerFlags, report->NestedExceptionReportRecord, whatever); 450 LIBCLOG_MSG2("!!! num %08lx flags %08lx nested %p whatever %p\n", 451 report->ExceptionNum, report->fHandlerFlags, (void *)report->NestedExceptionReportRecord, whatever); 445 452 if (report->fHandlerFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) 446 453 return XCPT_CONTINUE_SEARCH; … … 509 516 510 517 511 void _sys_get_clock(unsigned long *ms)512 {513 ULONG val_ms;514 FS_VAR();515 516 FS_SAVE_LOAD();517 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &val_ms, sizeof (val_ms));518 FS_RESTORE();519 *ms = val_ms;520 }521 522 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__initdll.c
-
Property cvs2svn:cvs-rev
changed from
1.11
to1.12
r1460 r1461 17 17 #include "libc-alias.h" 18 18 #define INCL_DOS 19 #define INCL_FSMACROS 19 20 #include <os2emx.h> 20 21 #define _osmajor __osminor … … 40 41 #pragma weak __init_largefileio 41 42 43 42 44 /******************************************************************************* 43 45 * Structures and Typedefs * … … 83 85 PPIB ppib; 84 86 __LIBC_PSPMPROCESS pSelf; 87 85 88 static int fInitialized = 0; 86 89 … … 177 180 * Init file handles. 178 181 */ 179 rc = __libc_fhInit( pSelf->pInherit ? pSelf->pInherit->pFHBundles : NULL);182 rc = __libc_fhInit(); 180 183 if (rc) 181 184 { … … 190 193 return 0; 191 194 } 195 196 197 /** 198 * Get the current MS timestamp. 199 * @param pms Where to store the current timestamp. 200 */ 201 void _sys_get_clock(unsigned long *pms) 202 { 203 ULONG val_ms; 204 FS_VAR(); 205 206 FS_SAVE_LOAD(); 207 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &val_ms, sizeof(val_ms)); 208 FS_RESTORE(); 209 *pms = val_ms; 210 } 211 192 212 193 213 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__spawnve.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1460 r1461 7 7 #include <errno.h> 8 8 #include <alloca.h> 9 #include <386/builtin.h> 10 #include <sys/fmutex.h> 9 11 #define INCL_DOSPROCESS 10 12 #define INCL_FSMACROS … … 192 194 *arg_ptr++ = '\0'; 193 195 *arg_ptr++ = '\0'; 196 197 _fmutex_request(&__libc_gmtxExec, 0); 194 198 195 199 /* … … 218 222 if (arg_buf != NULL) 219 223 _tfree (arg_buf); 224 _fmutex_release(&__libc_gmtxExec); 220 225 221 226 /* exit depends on the mode. */ … … 246 251 if (arg_buf != NULL) 247 252 _tfree (arg_buf); 253 _fmutex_release(&__libc_gmtxExec); 248 254 return -1; 249 255 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/filehandles.c
-
Property cvs2svn:cvs-rev
changed from
1.10
to1.11
r1460 r1461 41 41 #include "libc-alias.h" 42 42 #include <malloc.h> 43 #include <string.h> 43 44 #include <sys/fcntl.h> 44 45 #include <errno.h> … … 95 96 * @returns 0 on success. 96 97 * @returns -1 on failure. 97 * @param pInherit Pointer to inherited filehandle data.98 */ 99 int __libc_fhInit(__LIBC_PSPMINHFHBHDR pInherit) 100 { 101 ULONG cMaxFHs = 0;102 LONG lDeltaFHs = 0;103 int rc;104 int i;98 */ 99 int __libc_fhInit(void) 100 { 101 __LIBC_PSPMINHERIT pInherit; 102 ULONG cMaxFHs = 0; 103 LONG lDeltaFHs = 0; 104 int rc; 105 int i; 105 106 106 107 /* … … 136 137 gcPreAllocatedAvail = sizeof(gaPreAllocated) / sizeof(gaPreAllocated[0]); 137 138 138 139 if (!pInherit) 139 /* 140 * Check if we inherited flags and stuff from parent. 141 */ 142 pInherit = __libc_spmInheritRequest(); 143 if (!pInherit || pInherit->pFHBundles) 140 144 { 141 145 /* … … 165 169 void *pv; 166 170 } u; 167 u.pHdr = pInherit ;171 u.pHdr = pInherit->pFHBundles; 168 172 while (u.pHdr->uchType != __LIBC_SPM_INH_FHB_TYPE_END) 169 173 { … … 179 183 { 180 184 LIBC_ASSERTM_FAILED("Failed to allocated inherited file handle! iFH=%d\n", iFH); 185 __libc_spmInheritRelease(); 181 186 return -1; 182 187 } … … 192 197 LIBC_ASSERTM_FAILED("Failed to allocated inherited socket (4.4) handle! iFH=%d iSocket=%d\n", 193 198 iFH, u.pSockets->aHandles[i].usSocket); 199 __libc_spmInheritRelease(); 194 200 return -1; 195 201 } … … 205 211 LIBC_ASSERTM_FAILED("Failed to allocated inherited socket (4.3) handle! iFH=%d iSocket=%d\n", 206 212 iFH, u.pSockets->aHandles[i].usSocket); 213 __libc_spmInheritRelease(); 207 214 return -1; 208 215 } … … 224 231 } 225 232 } 233 __libc_spmInheritRelease(); 226 234 } 227 235 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sharedpm.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1460 r1461 113 113 static VOID APIENTRY spmExitList(ULONG ulReason); 114 114 static void spmZombieOrFree(__LIBC_PSPMPROCESS pProcess); 115 static unsigned spmTimestamp(void); 115 116 static __LIBC_PSPMPROCESS spmRegisterSelf(pid_t pid, pid_t pidParent); 116 117 static __LIBC_PSPMPROCESS spmAllocProcess(void); … … 121 122 static ULONG _System spmXcptHandler(PEXCEPTIONREPORTRECORD pRepRec, PEXCEPTIONREGISTRATIONRECORD pRegRec, PCONTEXTRECORD pCtx, PVOID pvWhatever); 122 123 static int spmCheck(int fBreakpoint, int fVerbose); 123 124 124 125 125 … … 296 296 297 297 /** 298 * Gets the inherit data associated with the current process. 299 * This call prevents it from being release by underrun handling. 300 * 301 * @returns Pointer to inherit data. 302 * The caller must call __libc_spmInheritRelease() when done. 303 * @returns NULL and errno if no inherit data. 304 */ 305 __LIBC_PSPMINHERIT __libc_spmInheritRequest(void) 306 { 307 LIBCLOG_ENTER("\n"); 308 __LIBC_PSPMINHERIT pRet = NULL; 309 __LIBC_SPMXCPTREGREC RegRec; 310 if (!spmRequestMutex(&RegRec)) 311 { 312 if ((pRet = gpSPMSelf->pInherit) != NULL) 313 gpSPMSelf->pInheritLocked = (void *)__atomic_xchg((unsigned *)(void *)&gpSPMSelf->pInherit, 0); 314 else if (gpSPMSelf->pInheritLocked) 315 { 316 errno = EBUSY; 317 LIBC_ASSERTM_FAILED("Already locked!\n"); 318 } 319 else 320 errno = 0; 321 spmReleaseMutex(&RegRec); 322 } 323 324 LIBCLOG_RETURN_P(pRet); 325 } 326 327 328 /** 329 * Releases the inherit data locked by the __libc_spmInheritRequest() call. 330 * 331 * @returns 0 on success. 332 * @returns -1 and errno on failure. 333 */ 334 int __libc_spmInheritRelease(void) 335 { 336 LIBCLOG_ENTER("\n"); 337 __LIBC_SPMXCPTREGREC RegRec; 338 int rc = spmRequestMutex(&RegRec); 339 if (!rc) 340 { 341 gpSPMSelf->pInheritLocked = (void *)__atomic_xchg((unsigned *)(void *)&gpSPMSelf->pInherit, (unsigned)gpSPMSelf->pInheritLocked); 342 spmReleaseMutex(&RegRec); 343 } 344 else 345 { 346 errno = EINVAL; 347 rc = -1; 348 LIBC_ASSERTM_FAILED("Not initialized!\n"); 349 } 350 351 LIBCLOG_RETURN_INT(rc); 352 } 353 354 355 /** 356 * Frees the inherit data of this process. 357 * This is called when the executable is initialized. 358 */ 359 void __libc_spmInheritFree(void) 360 { 361 LIBCLOG_ENTER("\n"); 362 if (gpSPMSelf && (gpSPMSelf->pInherit || gpSPMSelf->pInheritLocked)) 363 { 364 __LIBC_SPMXCPTREGREC RegRec; 365 if (!spmRequestMutex(&RegRec)) 366 { 367 if (gpSPMSelf->pInherit) 368 { 369 int rc = spmFree(gpSPMSelf->pInherit); 370 LIBC_ASSERTM(!rc, "Failed to free inherit memory %p, errno=%d.\n", 371 (void *)gpSPMSelf->pInherit, errno); 372 __atomic_xchg((unsigned *)(void *)&gpSPMSelf->pInherit, 0); 373 rc = rc; 374 } 375 LIBC_ASSERTM(!gpSPMSelf->pInheritLocked, "Trying to free a locked inherit struct!\n"); 376 377 spmReleaseMutex(&RegRec); 378 } 379 } 380 LIBCLOG_RETURN_VOID(); 381 } 382 383 384 385 /** 298 386 * Create an embryo related to the current process. 299 387 * … … 325 413 326 414 /* 415 * Reap old embryos. 416 */ 417 pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO]; 418 if (pProcess) 419 { 420 unsigned uTimestamp = spmTimestamp(); 421 do 422 { 423 SPM_ASSERT_PTR_NULL(pProcess); 424 SPM_ASSERT_PTR_NULL(pProcess->pPrev); 425 SPM_ASSERT_PTR_NULL(pProcess->pNext); 426 if ( pProcess->pidParent == pidParent 427 && pProcess->cReferences == 0 428 && uTimestamp - pProcess->uTimestamp >= 1*60*1000) 429 { 430 __LIBC_PSPMPROCESS pProcessNext = pProcess->pNext; 431 spmFreeProcess(pProcess); 432 pProcess = pProcessNext; 433 continue; 434 } 435 436 /* next */ 437 pProcess = pProcess->pNext; 438 } while (pProcess); 439 } 440 441 /* 327 442 * Create a new process block. 328 443 */ … … 333 448 * Initialize the new process block. 334 449 */ 335 pProcess->uVersion = SPM_VERSION; 336 pProcess->cReferences = 1; 337 pProcess->pid = -1; 338 pProcess->pidParent = pidParent; 339 pProcess->enmState = __LIBC_PROCSTATE_EMBRYO; 340 pProcess->cPoolPointers = 1; /** @todo define for this! */ 450 pProcess->uVersion = SPM_VERSION; 451 pProcess->cReferences = 1; 452 pProcess->pid = -1; 453 pProcess->pidParent = pidParent; 454 pProcess->enmState = __LIBC_PROCSTATE_EMBRYO; 455 pProcess->uTimestamp = spmTimestamp(); 456 pProcess->cPoolPointers = 2; /** @todo define for this! */ 341 457 342 458 /* link into list. */ … … 488 604 /* 489 605 * Free the process. 490 */ 491 if (pProcess->cReferences == 0) 606 * Note that we do not free embryos. We'll reap them at other places 607 * if they don't become alive. 608 */ 609 if (pProcess->cReferences == 0 && pProcess->enmState != __LIBC_PROCSTATE_EMBRYO) 492 610 spmFreeProcess(pProcess); 493 611 … … 1168 1286 else if (pProcess->enmState != __LIBC_PROCSTATE_ZOMBIE) 1169 1287 { 1288 /* free data a zombie won't be needing. */ 1289 if (pProcess->pInherit) 1290 { 1291 spmFree(pProcess->pInherit); 1292 pProcess->pInherit = NULL; 1293 } 1294 1170 1295 /* unlink. */ 1171 1296 if (pProcess->pNext) … … 1185 1310 } 1186 1311 /* else already zombie */ 1312 } 1313 1314 1315 /** 1316 * Gets the current timestamp. 1317 * 1318 * @returns The current timestamp. 1319 */ 1320 static unsigned spmTimestamp(void) 1321 { 1322 ULONG ul; 1323 int rc; 1324 FS_VAR(); 1325 FS_SAVE_LOAD(); 1326 ul = 0; 1327 rc = DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ul, sizeof(ul)); 1328 LIBC_ASSERTM(!rc, "DosQuerySysInfo failed rc=%d\n", rc); 1329 FS_RESTORE(); 1330 rc = rc; 1331 return (unsigned)ul; 1187 1332 } 1188 1333 … … 1298 1443 * Initialize the new process block. 1299 1444 */ 1300 pProcess->uVersion = SPM_VERSION; 1301 pProcess->cReferences = 1; 1302 pProcess->pid = pid; 1303 pProcess->pidParent = pidParent; 1304 pProcess->enmState = __LIBC_PROCSTATE_ALIVE; 1305 pProcess->cPoolPointers = 1; /** @todo define for this! */ 1445 pProcess->uVersion = SPM_VERSION; 1446 pProcess->cReferences = 1; 1447 pProcess->pid = pid; 1448 pProcess->pidParent = pidParent; 1449 pProcess->enmState = __LIBC_PROCSTATE_ALIVE; 1450 pProcess->uTimestamp = spmTimestamp(); 1451 pProcess->cPoolPointers = 2; /** @todo define for this! */ 1306 1452 1307 1453 /* link into list. */ … … 1444 1590 { 1445 1591 __LIBC_PSPMPROCESS pProcess; 1592 1593 /* 1594 * Free embryos which are more than 15 seconds old. 1595 */ 1596 pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO]; 1597 if (pProcess) 1598 { 1599 unsigned uTimestamp = spmTimestamp(); 1600 do 1601 { 1602 SPM_ASSERT_PTR_NULL(pProcess); 1603 SPM_ASSERT_PTR_NULL(pProcess->pNext); 1604 SPM_ASSERT_PTR_NULL(pProcess->pPrev); 1605 if ( pProcess->cReferences == 0 1606 && uTimestamp - pProcess->uTimestamp >= 15*1000) 1607 { 1608 __LIBC_PSPMPROCESS pProcessNext = pProcess->pNext; 1609 spmFreeProcess(pProcess); 1610 pProcess = pProcessNext; 1611 continue; 1612 } 1613 1614 /* next */ 1615 pProcess = pProcess->pNext; 1616 } while (pProcess); 1617 } 1618 1446 1619 /* 1447 1620 * Free up free processes. … … 1449 1622 while ((pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_FREE]) != NULL) 1450 1623 { 1624 SPM_ASSERT_PTR_NULL(pProcess); 1625 SPM_ASSERT_PTR_NULL(pProcess->pNext); 1626 SPM_ASSERT_PTR_NULL(pProcess->pPrev); 1627 gpSPMHdr->apHeads[__LIBC_PROCSTATE_FREE] = pProcess->pNext; 1451 1628 if (pProcess->pNext) 1452 1629 pProcess->pNext->pPrev = NULL; … … 1458 1635 1459 1636 /* 1460 * Free up inherit data .1637 * Free up inherit data of processes in the alive list. 1461 1638 */ 1462 1639 for (pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE]; pProcess; pProcess = pProcess->pNext) 1640 { 1641 SPM_ASSERT_PTR_NULL(pProcess); 1642 SPM_ASSERT_PTR_NULL(pProcess->pNext); 1643 SPM_ASSERT_PTR_NULL(pProcess->pPrev); 1463 1644 if (pProcess->pInherit) 1464 1645 { 1465 void *pv = pProcess->pInherit; 1466 pProcess->pInherit = NULL; 1646 void *pv = (void *)__atomic_xchg((unsigned *)(void *)&gpSPMSelf->pInherit, 0); 1467 1647 spmFree(pv); 1468 1648 } 1469 1470 /* 1471 * Free embryos which are more than a minutte old. 1472 */ 1473 /** @todo */ 1649 } 1474 1650 1475 1651 /* … … 1708 1884 SPM_ASSERT_PTR_NULL(pLeft->core.pPrev); 1709 1885 1710 if ( pLeft == pFree->core.pPrev)1886 if ((__LIBC_PSPMPOOLCHUNK)pLeft == pFree->core.pPrev) 1711 1887 { /* merge with left free chunk. */ 1712 1888 pLeft->core.pNext = pFree->core.pNext; … … 1733 1909 1734 1910 /* Check if we can merge with right hand free chunk. */ 1735 if (pRight && pRight == pFree->core.pNext)1911 if (pRight && (__LIBC_PSPMPOOLCHUNK)pRight == pFree->core.pNext) 1736 1912 { /* merge with right free chunk. */ 1737 1913 pFree->core.pNext = pRight->core.pNext; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/syscalls.h
-
Property cvs2svn:cvs-rev
changed from
1.11
to1.12
r1460 r1461 166 166 extern int _sys_init_environ(const char *pszEnv); 167 167 extern void _sys_init_largefileio(void); 168 extern int __libc_fhInit( __LIBC_PSPMINHFHBHDR pInherit);168 extern int __libc_fhInit(void); 169 169 /** @} */ 170 170 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.