Esempio n. 1
0
void initThreadmgr()
{
        globals_t *globals = getGlobals();

        globals->threadmgrSema = sceKernelCreateSema("vhlThreadmgrSema", 0,
                                        MAX_THREADS_NUM, MAX_THREADS_NUM, NULL);
        globals->threadmgrMutex = sceKernelCreateMutex("vhlThreadmgrMutex", 0, 0, NULL);
}
Esempio n. 2
0
void ExCancelTcb::registerSubtasks()
{
  ex_tcb::registerSubtasks();

  // register a non-queue event for the IPC with the send top node
  ioSubtask_ =
    getGlobals()->getScheduler()->registerNonQueueSubtask(sWork,this);
}
Esempio n. 3
0
/*  This guy calls the visitor from within the mutext lock, so the visitor
    cannot:
    - take too much time
    - try to acquire the mutext again
    - call a fontscaler (which might call into the cache)
*/
SkGlyphCache* SkGlyphCache::VisitCache(SkTypeface* typeface,
                              const SkDescriptor* desc,
                              bool (*proc)(const SkGlyphCache*, void*),
                              void* context) {
    if (!typeface) {
        typeface = SkTypeface::GetDefaultTypeface();
    }
    SkASSERT(desc);

    SkGlyphCache_Globals& globals = getGlobals();
    SkAutoMutexAcquire    ac(globals.fMutex);
    SkGlyphCache*         cache;
    bool                  insideMutex = true;

    globals.validate();

    for (cache = globals.internalGetHead(); cache != NULL; cache = cache->fNext) {
        if (cache->fDesc->equals(*desc)) {
            globals.internalDetachCache(cache);
            goto FOUND_IT;
        }
    }

    /* Release the mutex now, before we create a new entry (which might have
        side-effects like trying to access the cache/mutex (yikes!)
    */
    ac.release();           // release the mutex now
    insideMutex = false;    // can't use globals anymore

    // Check if we can create a scaler-context before creating the glyphcache.
    // If not, we may have exhausted OS/font resources, so try purging the
    // cache once and try again.
    {
        // pass true the first time, to notice if the scalercontext failed,
        // so we can try the purge.
        SkScalerContext* ctx = typeface->createScalerContext(desc, true);
        if (!ctx) {
            getSharedGlobals().purgeAll();
            ctx = typeface->createScalerContext(desc, false);
            SkASSERT(ctx);
        }
        cache = SkNEW_ARGS(SkGlyphCache, (typeface, desc, ctx));
    }

FOUND_IT:

    AutoValidate av(cache);

    if (!proc(cache, context)) {   // need to reattach
        if (insideMutex) {
            globals.internalAttachCacheToHead(cache);
        } else {
            globals.attachCacheToHead(cache);
        }
        cache = NULL;
    }
    return cache;
}
Int32 ExHdfsFastExtractTcb::fixup()
{
  lobGlob_ = NULL;

  ex_tcb::fixup();

  if(!myTdb().getSkipWritingToFiles() &&
     !myTdb().getBypassLibhdfs())
    memset (hdfsHost_, '\0', sizeof(hdfsHost_));
      strncpy(hdfsHost_, myTdb().getHdfsHostName(), sizeof(hdfsHost_));
      hdfsPort_ = myTdb().getHdfsPortNum();
    ExpLOBinterfaceInit
      (lobGlob_, getGlobals()->getDefaultHeap(),getGlobals()->castToExExeStmtGlobals()->getContext(),TRUE,hdfsHost_,hdfsPort_);

  modTS_ = myTdb().getModTSforDir();

  return 0;
}
Esempio n. 5
0
int waitAllUserThreadsEndCB(SceUInt *timeout)
{
        SceUID uid = getGlobals()->threadmgrSema;
        int res;

        res = sceKernelWaitSemaCB(uid, MAX_THREADS_NUM, timeout);
        if (res)
                return res;

        return sceKernelSignalSema(uid, MAX_THREADS_NUM);
}
Esempio n. 6
0
SkEventSink::SkEventSink() : fTagHead(NULL) {
    SkEventSink_Globals& globals = getGlobals();

    globals.fSinkMutex.acquire();

    fID = ++globals.fNextSinkID;
    fNextSink = globals.fSinkHead;
    globals.fSinkHead = this;

    globals.fSinkMutex.release();
}
Esempio n. 7
0
int nid_storage_initialize()
{
        nidTable_entry *nid_storage_table = getGlobals()->nid_storage_table;

        for(int i = 0; i < NID_STORAGE_BUCKET_COUNT; i++)
        {
                nid_storage_table[i * NID_STORAGE_MAX_BUCKET_ENTRIES].nid = 0;
        }

        return 0;
}
short ExExeUtilTcb::getObjectUid(char * catName, char * schName, 
				 char * objName, 
				 NABoolean isIndex, NABoolean isMv,
				 char* uid)
{
  Lng32 cliRC = 0;

  ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
  ExExeUtilPrivateState & pstate =
    *((ExExeUtilPrivateState*) pentry_down->pstate);

  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();

  const QueryString * qs;
  Int32 sizeOfqs = 0;
  versionStrLen_ = 0;
  
  qs = getObjectUidQuery;
  sizeOfqs = sizeof(getObjectUidQuery);
  
  Int32 qryArraySize = sizeOfqs / sizeof(QueryString);
  char * gluedQuery;
  Lng32 gluedQuerySize;
  glueQueryFragments(qryArraySize,  qs,
		     gluedQuery, gluedQuerySize);
  
  Lng32 extraSpace = 10 /*segment name*/+ ComMAX_3_PART_EXTERNAL_UTF8_NAME_LEN_IN_BYTES/*cat/sch/obj name in UTF8*/ + 100;
  
  char * infoQuery =
    new(getHeap()) char[gluedQuerySize + extraSpace + 1];
  
  str_sprintf(infoQuery, gluedQuery,
	      catName, schName, objName, 
	      (isIndex ? "IX" : "TA"),
	      (isMv ? "MV" : (isIndex ? "IX" : "BT")));

  NADELETEBASIC(gluedQuery, getMyHeap());
  
  Lng32 uidLen;
  cliRC = 
    cliInterface()->executeImmediate(infoQuery, 
				     uid, &uidLen);
  if (cliRC < 0)
    {
      cliInterface()->retrieveSQLDiagnostics(getDiagsArea());
      return -1;
    }
  uid[uidLen] = 0;

  return 0;
}
void ExSequenceTcb::registerSubtasks()
{
    ExScheduler *sched = getGlobals()->getScheduler();
    ex_tcb :: registerSubtasks();
    // Regsiter the I/O event, if overflow is possible
    if ( isUnboundedFollowing() ) {
      ioEventHandler_ = sched->registerNonQueueSubtask(sWork,this); 
      // work around: The handler was just created, while clusterDb was created
      // earlier (in the TCB ctor), so update clusterDb now with the handler
      ex_assert( clusterDb_ , "Unlimited following and no clusterDb_") ;
      clusterDb_->ioEventHandler_ = ioEventHandler_ ;
    }
};
short ExExeUtilTcb::lockUnlockObject(char * tableName,
				     NABoolean lock,
				     NABoolean parallel,
				     char * failReason)
{
  char buf[4000];
  Lng32 cliRC = 0;

  // Get the globals stucture of the master executor.
  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();

  // lock or unlock the table.
  if (parallel)
    {
      if (lock)
	str_sprintf(buf, "LOCK TABLE %s IN PROTECTED MODE NO INDEX LOCK PARALLEL EXECUTION ON",
		    tableName);
      else
	str_sprintf(buf, "UNLOCK TABLE %s PARALLEL EXECUTION ON",
		    tableName);
    }
  else
    {
      if (lock)
	str_sprintf(buf, "LOCK TABLE %s IN PROTECTED MODE",
		    tableName);
      else
	str_sprintf(buf, "UNLOCK TABLE %s",
		    tableName);
    }
  masterGlob->getStatement()->getContext()->setSqlParserFlags(0x100001);
  
  cliRC = cliInterface()->executeImmediate(buf);
  
  masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x100001);
  
  if (cliRC < 0)
    {
      if (lock)
	str_sprintf(failReason, "Could not lock table %s in protected mode using parallel execution.",
		    tableName);
      else
	str_sprintf(failReason, "Could not unlock table %s using parallel execution.",
		    tableName);

      return -1;
    }
  
  return 0;
}
Esempio n. 11
0
ExOperStats * ex_tcb::doAllocateStatsEntry(CollHeap *heap, ComTdb *tdb)
{
  ComTdb::CollectStatsType statsType = getGlobals()->getStatsArea()->getCollectStatsType();
  if (statsType == ComTdb::OPERATOR_STATS || statsType == ComTdb::ALL_STATS)
    return new(heap) ExOperStats(heap,
			       ExOperStats::EX_OPER_STATS,
			       this,
			       tdb);
  else
  {
    ex_assert(FALSE, "doAllocateStatsEntry is not implemented by the TCB");
    return NULL;
  }
}
Lng32 ExExeUtilTcb::changeAuditAttribute(char * tableName,
					NABoolean makeAudited,
					NABoolean isVolatile,
					NABoolean isIndex,
					NABoolean parallelAlter)
{
  Lng32 retcode = 0;

  // Get the globals stucture of the master executor.
  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();

  // set sqlparserflags to allow change of audit attribute
  masterGlob->getStatement()->getContext()->setSqlParserFlags(0x400); // ALLOW_AUDIT_CHANGE	
  
  // make table unaudited
  char stmt[500];
  strcpy(stmt, "alter ");
  if (isVolatile)
    strcat(stmt, "volatile ");
  strcat(stmt, "table ");
  strcat(stmt, tableName);
  if (makeAudited)
    strcat(stmt, " attribute audit");
  else
    strcat(stmt, " attribute no audit");

  if (parallelAlter)
    strcat(stmt, " no label update");

  strcat(stmt, ";");

  retcode = cliInterface()->executeImmediate
    (stmt, NULL, NULL, TRUE, NULL, 0,
     &(masterGlob->getStatement()->getContext()->diags()));

  masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x400); // ALLOW_AUDIT_CHANGE
  
  if (retcode < 0)
    return retcode;

  if (parallelAlter)
    {
      retcode = alterAuditFlag(makeAudited, tableName, isIndex);
      if (retcode < 0)
	return retcode;
    }

  return 0;
}
Esempio n. 13
0
// If statistics are to be collected and an entry for this
// node doesn't already exist in stats area passed in, 
// allocate one and add to it. Else, make pstate's stat pointer
// point to this entry.
void ex_tcb::allocateStatsEntry(CollHeap * heap) {
  
  // temporarily enable stats. Done so we can build stats related
  // structs, if asked for by the compiler.
  NABoolean statsEnabled = getGlobals()->statsEnabled();
  getGlobals()->setStatsEnabled(TRUE);
  
  if (getGlobals()->getStatsArea()) {
    
    // allocate a new stats entry
    ExOperStats* stat = NULL;
    if (needStatsEntry())
      stat = doAllocateStatsEntry(getGlobals()->getStatsArea()->getHeap(),
				  ((ComTdb *)getTdb()));
    if (stat)
      {
	// the queue sizes from the generator are just
	// estimates. Set the correct values here.
	if (getParentQueue().down) {
	  stat->setDownQueueSize(getParentQueue().down->getSize());
	  stat->setUpQueueSize(getParentQueue().up->getSize());
	}
	else {
	  stat->setDownQueueSize((queue_index) 0);
	  stat->setUpQueueSize((queue_index) 0); 
	};
	
	// add this entry to the stats area
	getGlobals()->getStatsArea()->insert(stat);
	
	setStatsEntry(stat);
      }

    // now allocate the stats entries of my children
    Int32 nc = numChildren();
    for (Int32 i = 0; i < nc; i++)
      {
	if (getChild(i) != NULL)
	  {
	    ex_tcb * childTcb = (ex_tcb*)getChild(i);
	    childTcb->allocateStatsEntry(getGlobals()->getStatsArea()->getHeap());
	  }
      }

    // assign my TDB id as parent ID to my children
    if (stat && nc)
      propagateTdbIdForStats(getTdb()->getTdbId());
  } // stats area present

  getGlobals()->setStatsEnabled(statsEnabled);
}
Int32 ExHdfsFastExtractTcb::fixup()
{
  lobGlob_ = NULL;

  ex_tcb::fixup();

  if(!myTdb().getSkipWritingToFiles() &&
     !myTdb().getBypassLibhdfs())

    ExpLOBinterfaceInit
      (lobGlob_, getGlobals()->getDefaultHeap(),TRUE);

  modTS_ = myTdb().getModTSforDir();

  return 0;
}
Esempio n. 15
0
void SkGlyphCache::VisitAllCaches(bool (*proc)(SkGlyphCache*, void*),
                                  void* context) {
    SkGlyphCache_Globals& globals = getGlobals();
    SkAutoMutexAcquire    ac(globals.fMutex);
    SkGlyphCache*         cache;

    globals.validate();

    for (cache = globals.internalGetHead(); cache != NULL; cache = cache->fNext) {
        if (proc(cache, context)) {
            break;
        }
    }

    globals.validate();
}
Esempio n. 16
0
int nid_storage_getEntry(SceNID nid, nidTable_entry *entry)
{
        nidTable_entry *nid_storage_table = getGlobals()->nid_storage_table;
        int key = (char)(nid >> 24);

        for(int i = (key * NID_STORAGE_MAX_BUCKET_ENTRIES); i < (key + 1) * NID_STORAGE_MAX_BUCKET_ENTRIES; i++)
        {
                if(nid_storage_table[i].nid == nid) {
                        entry->nid = nid_storage_table[i].nid;
                        entry->type = nid_storage_table[i].type;
                        entry->value.i = nid_storage_table[i].value.i;
                        return 0;
                }
        }
        return -1;
}
Esempio n. 17
0
SkEventSink* SkEventSink::FindSink(SkEventSinkID sinkID)
{
    if (sinkID == 0)
        return 0;

    SkEventSink_Globals&    globals = getGlobals();
    SkAutoMutexAcquire      ac(globals.fSinkMutex);
    SkEventSink*            sink = globals.fSinkHead;

    while (sink)
    {
        if (sink->getSinkID() == sinkID)
            return sink;
        sink = sink->fNextSink;
    }
    return NULL;
}
Esempio n. 18
0
void ExProbeCacheTcb::registerSubtasks()
{
  ExScheduler *sched = getGlobals()->getScheduler();

  sched->registerInsertSubtask(sWorkDown,   this, qparent_.down,"PD");
  sched->registerUnblockSubtask(sWorkDown,  this, qchild_.down, "PD");

  sched->registerInsertSubtask(sWorkUp,     this, qchild_.up,   "PU");
  sched->registerUnblockSubtask(sWorkUp,    this, qparent_.up,  "PU");

  sched->registerCancelSubtask(sCancel,     this, qparent_.down,"CN");

  // We need to schedule workUp from workDown if a call to workDown 
  // has changed any request to either CACHE_HIT or CANCELED_NOT_STARTED 
  // and if it has not changed any request to CACHE_MISS.
  workUpTask_ = sched->registerNonQueueSubtask(sWorkUp, this, "PU");

}
////////////////////////////////////////////////////////////////////////
// Register subtasks 
//
void ExFirstNTcb::registerSubtasks()
{
  ExScheduler *sched = getGlobals()->getScheduler();
  ex_queue_pair pQueue = getParentQueue();

  // register events for parent queue
  ex_assert(pQueue.down && pQueue.up,"Parent down queue must exist");
  sched->registerInsertSubtask(ex_tcb::sWork, this, pQueue.down);
  sched->registerCancelSubtask(sCancel, this, pQueue.down);
  sched->registerUnblockSubtask(ex_tcb::sWork,this, pQueue.up);

  // register events for child queues
  const ex_queue_pair cQueue = getChild(0)->getParentQueue();

  sched->registerUnblockSubtask(ex_tcb::sWork,this, cQueue.down);
  sched->registerInsertSubtask(ex_tcb::sWork, this, cQueue.up);

}
Esempio n. 20
0
bool CSMWorld::Data::hasId (const std::string& id) const
{
    return
        getGlobals().searchId (id)!=-1 ||
        getGmsts().searchId (id)!=-1 ||
        getSkills().searchId (id)!=-1 ||
        getClasses().searchId (id)!=-1 ||
        getFactions().searchId (id)!=-1 ||
        getRaces().searchId (id)!=-1 ||
        getSounds().searchId (id)!=-1 ||
        getScripts().searchId (id)!=-1 ||
        getRegions().searchId (id)!=-1 ||
        getBirthsigns().searchId (id)!=-1 ||
        getSpells().searchId (id)!=-1 ||
        getTopics().searchId (id)!=-1 ||
        getJournals().searchId (id)!=-1 ||
        getCells().searchId (id)!=-1 ||
        getReferenceables().searchId (id)!=-1;
}
Esempio n. 21
0
void ex_tcb::mergeStats(ExStatisticsArea *otherStats)
{
  ex_globals * glob = getGlobals();
  StatsGlobals *statsGlobals = glob->getStatsGlobals();
  Long semId;
  if (statsGlobals != NULL)
  {
    semId = glob->getSemId();
    short savedPriority, savedStopMode;
    short error = statsGlobals->getStatsSemaphore(semId, glob->getPid(), 
      savedPriority, savedStopMode,
      FALSE /*shouldTimeout*/);
    ex_assert(error == 0, "getStatsSemaphore() returned an error");
    glob->getStatsArea()->merge(otherStats);
    statsGlobals->releaseStatsSemaphore(semId, glob->getPid(), savedPriority, savedStopMode);
  }
  else
    glob->getStatsArea()->merge(otherStats);
}
Esempio n. 22
0
ExOperStats * ExProbeCacheTcb::doAllocateStatsEntry(CollHeap *heap,
                                                        ComTdb *tdb)
{
  ExOperStats * stat = NULL;
  ComTdb::CollectStatsType statsType = getGlobals()->getStatsArea()->getCollectStatsType();
  if (statsType == ComTdb::OPERATOR_STATS)
  {
    return ex_tcb::doAllocateStatsEntry(heap, tdb);
  }
  else
  {
    ExProbeCacheTdb * pcTdb = (ExProbeCacheTdb*) tdb;

    return new(heap) ExProbeCacheStats(heap,
                      this,
                      tdb,
                      pcTdb->bufferSize_,
                      pcTdb->cacheSize_);
  }
}
ExOperStats * ExFastExtractTcb::doAllocateStatsEntry(
                                              CollHeap *heap,
                                              ComTdb *tdb)
{
  ExOperStats *stat = NULL;

  ComTdb::CollectStatsType statsType = getGlobals()->getStatsArea()->getCollectStatsType();

  if (statsType == ComTdb::OPERATOR_STATS)
  {
    return ex_tcb::doAllocateStatsEntry(heap, tdb);;
  }
  else
  {

    return new(heap) ExFastExtractStats( heap,
                                         this,
                                         tdb);
  }
}
Esempio n. 24
0
// ExTransposeTcb::registerSubtasks() -------------------------------------
// Register all the transpose subtasks with the scheduler.
//
void ExTransposeTcb::registerSubtasks()
{
  ExScheduler *sched = getGlobals()->getScheduler();
  
  // down queues are handled by workDown()
  //

  // Schedule this routine if a new entry is inserted into the
  // parents down queue and we are waiting on an event.
  // (had returned WORK_OK).
  //
  sched->registerInsertSubtask(sWorkDown, this, qParent_.down, "DN");

  // Schedule this routine if the child's down queue changes from being
  // full to being not full and we are waiting on an event.
  // (had returned WORK_OK).
  //
  sched->registerUnblockSubtask(sWorkDown, this, childQueue_.down, "DN");
  
  // Schedule this routine if a cancel request occurs on the 
  // parents down queue.
  //
  sched->registerCancelSubtask(sCancel, this, qParent_.down, "CN");
  
  // up queues are handled by workUp()
  //

  // Schedule this routine if the parent's up queue changes from being
  // full to being not full and we are waiting on an event.
  // (had returned WORK_OK).
  //
  sched->registerUnblockSubtask(sWorkUp, this, qParent_.up,"UP");

  // Schedule this routine if a new entry is inserted into the
  // child's up queue and we are waiting on an event.
  // (had returned WORK_OK).
  //
  sched->registerInsertSubtask(sWorkUp, this, childQueue_.up);
}
Esempio n. 25
0
SceUID hook_sceKernelCreateThread(const char *name, SceKernelThreadEntry entry,
        int initPriority, SceSize stackSize, SceUInt attr,
        int cpuAffinityMask, const SceKernelThreadOptParam *option)
{
        SceKernelSemaInfo info;
        globals_t *globals;
        SceUID uid;
        int res;

        globals = getGlobals();
        sceKernelLockMutexCB(globals->threadmgrMutex, 1, NULL);

        res = sceKernelPollSema(globals->threadmgrSema, 1);
        if (res)
                goto force;

        info.size = sizeof(info);
        res = sceKernelGetSemaInfo(globals->threadmgrSema, &info);
        if (res)
                goto force;

        uid = sceKernelCreateThread(name, hookEntry, initPriority,
                                    stackSize, attr, cpuAffinityMask, option);
        if (uid >= 0) {
                globals->threadmgrTable[info.currentCount].uid = uid;
                globals->threadmgrTable[info.currentCount].entry = entry;
                globals->threadmgrTable[info.currentCount].exitDeleteCb = SCE_KERNEL_ERROR_ERROR;
        }

        sceKernelUnlockMutex(globals->threadmgrMutex, 1);

        return uid;

force:
        sceKernelUnlockMutex(globals->threadmgrMutex, 1);
        return sceKernelCreateThread(name, entry, initPriority,
                                     stackSize, attr, cpuAffinityMask, option);
}
Esempio n. 26
0
int nid_storage_addEntry(nidTable_entry *entry)
{
        nidTable_entry *nid_storage_table = getGlobals()->nid_storage_table;
        int key = (char)(entry->nid >> 24);

        for(int i = (key * NID_STORAGE_MAX_BUCKET_ENTRIES); i < NID_STORAGE_BUCKET_COUNT * NID_STORAGE_MAX_BUCKET_ENTRIES; i++)
        {
                if(nid_storage_table[i].nid == 0 || nid_storage_table[i].nid == entry->nid) { //Search for empty spot to add entry or update duplicate

                        //DEBUG_LOG("Entry %d", i);
                        //Make sure that the next entry is only cleared if we aren't overwriting an existing entry
                        if(nid_storage_table[i].nid != entry->nid && i + 1 < (key + 1) * NID_STORAGE_MAX_BUCKET_ENTRIES) nid_storage_table[i + 1].nid = 0;

                        nid_storage_table[i].nid = entry->nid;
                        nid_storage_table[i].type = entry->type;
                        nid_storage_table[i].value.i = entry->value.i;

                        return 0;
                }
        }
        DEBUG_LOG_("Failed to add NID");
        return -1;
}
Esempio n. 27
0
static int hookEntry(SceSize args, void *argp)
{
        SceKernelSemaInfo info;
        globals_t *globals;
        SceUID uid;
        int res;

        uid = sceKernelGetThreadId();
        globals = getGlobals();

        sceKernelLockMutexCB(globals->threadmgrMutex, 1, NULL);

        info.size = sizeof(info);
        res = sceKernelGetSemaInfo(globals->threadmgrSema, &info);
        if (res)
                goto fail;

        while (globals->threadmgrTable[info.currentCount].uid != uid) {
                if (info.currentCount >= info.maxCount) {
                        res = SCE_KERNEL_ERROR_ERROR;
                        goto fail;
                }

                info.currentCount++;
        }

        globals->threadmgrTable[info.currentCount].exitDeleteCb
                = sceKernelCreateCallback("vhlUserExitDeleteCb", 0, exitDeleteCb, NULL);

        sceKernelUnlockMutex(globals->threadmgrMutex, 1);

        return globals->threadmgrTable[info.currentCount].entry(args, argp);

fail:
        sceKernelUnlockMutex(globals->threadmgrMutex, 1);
        return res;
}
Esempio n. 28
0
void ExVPJoinTcb::registerSubtasks()
{
  ExScheduler *sched = getGlobals()->getScheduler();

  // parent and child down queues are handled by workDown()
  sched->registerInsertSubtask(sWorkDown, this, qParent_.down, "Work Down");
  sched->registerCancelSubtask(sWorkCancel, this, qParent_.down, "Work Cancel");
  Int32 i;
  for (i=0; i<numChildren_; i++)
    {
      sched->registerUnblockSubtask(sWorkDown, this, qChild_[i].down);
    }

  // parent and child up queues are handled by workUp()
  sched->registerUnblockSubtask(sWorkUp, this, qParent_.up, "Work Up");
  for (i=0; i<numChildren_; i++)
    {
      sched->registerInsertSubtask(sWorkUp, this, qChild_[i].up, "Work Up");
    }

  // make an event through which we can tell the scheduler to call
  // workUp().
  exceptionEvent_ = sched->registerNonQueueSubtask(sWorkUp, this);
}
Esempio n. 29
0
void ex_tcb::allocateParentQueues(ex_queue_pair &parentQueues,
				  NABoolean allocatePstate)
{
  CollHeap     *space   = getGlobals()->getSpace();
  const ComTdb *tdb     = getTdb();
  queue_index  downSize = tdb->initialQueueSizeDown_;
  queue_index  upSize   = tdb->initialQueueSizeUp_;

  parentQueues.down = new(space) ex_queue(ex_queue::DOWN_QUEUE,
					  downSize,
					  tdb->criDescDown_,
					  space);

  if (allocatePstate)
    {
      // Allocate the private state in each entry of the down queue
      parentQueues.down->allocatePstate(this);
    }

  parentQueues.up = new(space) ex_queue(ex_queue::UP_QUEUE,
					upSize,
					tdb->criDescUp_,
					space);
}
short ExExeUtilTcb::createServer(char *serverName,
				 const char * inPName,
				 IpcServerTypeEnum serverType,
				 IpcServerAllocationMethod servAllocMethod,
				 char *nodeName,
				 short cpu,
				 const char *partnName,
				 Lng32 priority,
				 IpcServer* &ipcServer,
				 NABoolean logError,
				 const char * operation)
{
  short error = 0;

 // Get the globals stucture of the master executor.
  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();

  IpcEnvironment * env = masterGlob->getCliGlobals()->getEnvironment(); 
  NAHeap *ipcHeap = masterGlob->getCliGlobals()->getIpcHeap();


  IpcServerClass * sc =
    new (ipcHeap) IpcServerClass(env, serverType,
				     servAllocMethod, //IPC_LAUNCH_GUARDIAN_PROCESS,
				     COM_VERS_MXV, nodeName);
  if (!sc)
    {
      if (logError)
        {
          char emsText[400+ComMAX_3_PART_EXTERNAL_UTF8_NAME_LEN_IN_BYTES];
          str_sprintf(emsText, "Failure creating IpcServerClass on \\%s cpu %d to %s %s for %s.", 
		      nodeName, cpu, operation, partnName, 
		      (char *)exeUtilTdb().getTableName());
          SQLMXLoggingArea::logExecRtInfo(NULL, 0, emsText, 0);
        }
      return -1;
    }

  const char * pName = NULL;
  char pNameBuf[20];
  short pNameLen = 0;

  if (inPName)
    pName = inPName;
  else
    {
      pName = pNameBuf;

      pNameBuf[pNameLen] = 0;
    }

  ipcServer =
    sc->allocateServerProcess(&diagsArea_,
			      ipcHeap,
			      nodeName,
			      cpu,
			      priority, 
			      1, // espLevel (not relevent)
			      FALSE, // no Xn
			      TRUE, // waited creation
			      0, // maxNowaitRequests
			      serverName,
			      pName
			      );
  if (!ipcServer)
    {
      if (logError && diagsArea_)
        {
          char emsText[400+ComMAX_3_PART_EXTERNAL_UTF8_NAME_LEN_IN_BYTES];
          str_sprintf(emsText, "allocateServerProcess() failed with error %d on \\%s cpu %d to %s %s for %s.", 
		      diagsArea_->mainSQLCODE(), nodeName, cpu, operation,
		      partnName, (char *)exeUtilTdb().getTableName());
          SQLMXLoggingArea::logExecRtInfo(NULL, 0, emsText, 0);
        }
      NADELETE(sc, IpcServerClass, ipcHeap);
      return -3;
    }

  return 0;
}