示例#1
0
ProcessId *ProcessId::create(Pid_t ppid, Pid_t id, int32_t flags)
{
  ProcessId *proc = pidPool.out();
  int32_t parentId = -1;

  if((ppid>=0)&&(pidTable[ppid])){
    ProcessId *pproc=pidTable[ppid];
    pproc->nChilds++;
    pproc->stats.nSpawns++;
    parentId = pproc->myId;
  }

  static int32_t uniqueId=0;
  proc->myId         = uniqueId++;

  proc->priority     =0;
  proc->ppid         = ppid;
  proc->parentId     = parentId;
  proc->pid          = id;
  proc->nChilds      = 0;
  proc->state        = InvalidState;
  proc->queuePosition= processQueue.end();
  proc->suspendedCounter = 0;

  proc->stats.reset();

  proc->spawnTime       = globalClock;
  proc->startTime       = globalClock;

#if (defined TLS)
  while(id>=(Pid_t)pidTable.size())
    pidTable.push_back(0);
#endif
  I( id < (Pid_t)pidTable.size() );
  I(pidTable[id] == 0);
  pidTable[id] = proc;

  proc->sysconf(flags);

  return proc;
}