コード例 #1
0
static void
init_thds(void)
{
	unsigned short int i;
	int mgr;

	/* initialize the spds first! */
	assert(ncomps);
	for (i = 0 ; i < MAX_NUM_THREADS ; i++) {
		int p;
		struct thd *t;
		struct component *c;
		
		p = periodic_wake_get_period(i);
		if (0 >= p) continue;
		t = create_thread();
		t->tid = i;
		t->sched_info.period = p;
		p = sched_priority(i);
		t->sched_info.priority = p;
		insert_thread(t);

		printc("TMEM Policy: Found thread %d.\n", i);

		for (mgr = 0 ; mgr < NUM_TMEM_MGR ; mgr++) {
			for (c = FIRST_LIST(&components[mgr], next, prev) ;
			     c != &components[mgr] ;
			     c = FIRST_LIST(c, next, prev)) {
				t->comp_info[c->mgr][c->spdid].c = c;
			}
		}
	}
}
コード例 #2
0
ファイル: threads.c プロジェクト: multics69/danbi
int
_papi_hwi_initialize_thread( ThreadInfo_t ** dest, int tid )
{
	int retval;
	ThreadInfo_t *thread;
	int i;

	if ( ( thread = allocate_thread( tid  ) ) == NULL ) {
		*dest = NULL;
		return PAPI_ENOMEM;
	}

	/* Call the substrate to fill in anything special. */

	for ( i = 0; i < papi_num_components; i++ ) {
		retval = _papi_hwd[i]->init( thread->context[i] );
		if ( retval ) {
			free_thread( &thread );
			*dest = NULL;
			return retval;
		}
	}

	insert_thread( thread, tid );

	*dest = thread;
	return PAPI_OK;
}
コード例 #3
0
ファイル: cpustat.c プロジェクト: bochf/testing
/* Name: BuildCPUTree
 * Description: Given a cpustats struct, build and "link" the CPU tree. 
 * Notes: This is an externally referenced API - read the full description in
 *        cpustat.h.
 */
int BuildCPUTree(struct cpustats *cpus)
{
   struct rawsyscpu *rscl;
   struct rawsyscpu *thisrsc;
   struct cpu_socket *cpu_tree;
   struct cpustat *thiscpus;
   int i;

   /* Make sure we are dealing with a real struct here */
   if ( NULL == cpus )
      return(1);

   /* Read in a linked list of CPU info */
   if (NULL == (rscl = read_sys_cpus()))
   {
      return(1);
   }

   /* Build out the cpu_sockets */
   thisrsc = rscl;
   cpu_tree = NULL;
   while( thisrsc )
   {
      cpu_tree = insert_socket(cpu_tree, thisrsc);
      thisrsc = thisrsc->next;
   }

   /* Build out the cpu_cores */
   thisrsc = rscl;
   while( thisrsc )
   {
      if(insert_core(cpu_tree, thisrsc))
         return(1);

      thisrsc = thisrsc->next;
   }

   /* Build out the cpu_threads */
   thisrsc = rscl;
   while( thisrsc )
   {
      if(insert_thread(cpu_tree, thisrsc))
         return(1);

      thisrsc = thisrsc->next;
   }

   thiscpus = cpus->cpulist;
   i = 0;
   while ( i < cpus->cpucnt )
   {
      if(insert_cpustat(cpu_tree, &thiscpus[i]))
         return(1);

      i++;
   }

   /* Only insert the tree when complete -> 100% successful */
   cpus->cpu_tree = cpu_tree;

   return(0);
}