Changeset 1085
- Timestamp:
- 10/04/08 23:57:06 (3 months ago)
- Files:
-
- 1 modified
-
Whitix/branches/keobject/kernel/process.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/keobject/kernel/process.c
r1079 r1085 6 6 #include <i386/process.h> 7 7 #include <malloc.h> 8 #include <keobject.h> 8 9 9 10 LIST_HEAD(processList); … … 12 13 struct Cache* processCache; 13 14 int pid=0; 15 16 KE_OBJECT_TYPE(processType, NULL, NULL); 17 struct KeSet processSet; 14 18 15 19 /*********************************************************************** … … 89 93 process->cId=1; /* Used to give IDs to threads. */ 90 94 91 if (current)92 process->refs++; /* For WaitForProcessFinish */93 94 95 process->state=THR_RUNNING; 95 96 … … 101 102 if (current) 102 103 ListAdd(&process->sibling, ¤t->children); 104 105 /* Create the process kernel object, and add it to /Processes. 106 * KeObjectInit is called in the slab constructor. */ 107 int err = KeObjectAttach(&process->object, "%d", process->pid); 108 109 struct KeFsEntry* dir = process->object.dir; 110 111 IcFsAddStrEntry(dir, "name", process->name); 103 112 104 113 ListAddTail(&process->next,&processList); … … 207 216 if (!process) 208 217 return -ENOENT; 218 219 ThrGetProcess(process); /* For WaitForProcessFinish */ 209 220 }else{ 210 221 /* Waiting for any of it's children, but what if it has none? */ … … 250 261 *finishStatus=(process->exitCode << 8); 251 262 252 if (process) 253 ThrReleaseProcess(process); 263 ThrPutProcess(process); 254 264 255 265 return retVal; … … 279 289 ZeroMemory(process,sizeof(struct Process)); 280 290 281 process->refs=1;282 291 INIT_WAITQUEUE_HEAD(&process->waitQueue); 283 292 INIT_LIST_HEAD(&process->areaList); 284 293 INIT_LIST_HEAD(&process->children); 294 KeObjectInit(&process->object, &processSet); 285 295 } 286 296 … … 303 313 304 314 /* Go through all the children and abandon them. */ 305 ListForEachEntry(currProc, ¤t->children,sibling)315 ListForEachEntry(currProc, ¤t->children, sibling) 306 316 { 307 Thr ReleaseProcess(currProc);317 ThrPutProcess(currProc); 308 318 currProc->parent=NULL; 309 319 } … … 338 348 339 349 /* Release all vmm areas */ 340 // MMapProcessRemove(current); 341 342 // if (VfsFreeFsContext) 343 // VfsFreeFsContext(); 350 MmapProcessRemove(current); 351 LoadReleaseFsContext(); 344 352 345 353 /* Now get rid of the memory manager - leaving kernel memory pages intact */ … … 368 376 } 369 377 370 Thr ReleaseProcess(current);378 ThrPutProcess(current); 371 379 current=NULL; /* Will reschedule as soon as possible - so no big deal, 372 380 waiters will have a reference to the process in question anyway. */ … … 414 422 SysRegisterRange(SYS_PROCESS_BASE, procSysCallTable); 415 423 424 /* Create the process set. Exposing the process via the filesystem allows 425 * us to do debugging in quite a nice way. */ 426 KeSetCreate(&processSet, NULL, &processType, "Processes"); 427 416 428 return 0; 417 429 }