Changeset 1085 for Whitix

Show
Ignore:
Timestamp:
10/04/08 23:57:06 (2 months ago)
Author:
mwhitworth
Message:

Add process set, add entry for each process (plus a temporary name file).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/branches/keobject/kernel/process.c

    r1079 r1085  
    66#include <i386/process.h> 
    77#include <malloc.h> 
     8#include <keobject.h> 
    89 
    910LIST_HEAD(processList); 
     
    1213struct Cache* processCache; 
    1314int pid=0; 
     15 
     16KE_OBJECT_TYPE(processType, NULL, NULL); 
     17struct KeSet processSet; 
    1418 
    1519/*********************************************************************** 
     
    8993        process->cId=1; /* Used to give IDs to threads. */ 
    9094 
    91         if (current) 
    92                 process->refs++; /* For WaitForProcessFinish */ 
    93  
    9495        process->state=THR_RUNNING; 
    9596 
     
    101102        if (current) 
    102103                ListAdd(&process->sibling, &current->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); 
    103112 
    104113        ListAddTail(&process->next,&processList); 
     
    207216                if (!process) 
    208217                        return -ENOENT; 
     218                         
     219                ThrGetProcess(process); /* For WaitForProcessFinish */ 
    209220        }else{ 
    210221                /* Waiting for any of it's children, but what if it has none? */ 
     
    250261                *finishStatus=(process->exitCode << 8); 
    251262 
    252         if (process) 
    253                 ThrReleaseProcess(process); 
     263        ThrPutProcess(process); 
    254264 
    255265        return retVal; 
     
    279289        ZeroMemory(process,sizeof(struct Process)); 
    280290 
    281         process->refs=1; 
    282291        INIT_WAITQUEUE_HEAD(&process->waitQueue); 
    283292        INIT_LIST_HEAD(&process->areaList); 
    284293        INIT_LIST_HEAD(&process->children); 
     294        KeObjectInit(&process->object, &processSet); 
    285295} 
    286296 
     
    303313 
    304314        /* Go through all the children and abandon them. */ 
    305         ListForEachEntry(currProc,&current->children,sibling) 
     315        ListForEachEntry(currProc, &current->children, sibling) 
    306316        { 
    307                 ThrReleaseProcess(currProc); 
     317                ThrPutProcess(currProc); 
    308318                currProc->parent=NULL; 
    309319        } 
     
    338348 
    339349        /* Release all vmm areas */ 
    340 //      MMapProcessRemove(current); 
    341  
    342 //      if (VfsFreeFsContext) 
    343 //              VfsFreeFsContext(); 
     350        MmapProcessRemove(current); 
     351        LoadReleaseFsContext(); 
    344352 
    345353        /* Now get rid of the memory manager - leaving kernel memory pages intact */ 
     
    368376        } 
    369377 
    370         ThrReleaseProcess(current); 
     378        ThrPutProcess(current); 
    371379        current=NULL; /* Will reschedule as soon as possible - so no big deal, 
    372380                                        waiters will have a reference to the process in question anyway. */ 
     
    414422        SysRegisterRange(SYS_PROCESS_BASE, procSysCallTable); 
    415423 
     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 
    416428        return 0; 
    417429}