Exemple #1
0
/***************************************\
* multiplexer message thread			*
\***************************************/
void incoming_sig_handler(int sig, siginfo_t *si, void *ucontext)
{
	struct uss_address addr;
	struct uss_message mess;
	union sigval sv = si->si_value;
	int wrapped_int = si->si_value.sival_int;

	convert_int_to_uss(wrapped_int, &addr, &mess);	

	pthread_sigqueue(multi_table[addr.lid].local_thread, SIGRTMIN+1, sv);
}
Exemple #2
0
static void converge_on_safepoint(struct PupHeap *heap,
                                  struct PupThreadInfo *tinfo)
{
	union sigval sv;
	sv.sival_ptr = heap;
	pthread_t thread = get_thread(tinfo);
	fprintf(stderr, "converge_on_safepoint() signalling %p\n", (void *)thread);
	int ret = pthread_sigqueue(thread, SIGUSR1, sv);
	ABORTF_ON(ret, "sigqueue() failed: %s", strerror(errno));
	safepoint_barrier_wait(heap);
}
Exemple #3
0
void *thread_function( void *arg)
{
	
  	int id,sig;
	sigset_t mask;
		 
// 	id = *((int *)arg);
	
struct taskControlBlock *data = (struct taskControlBlock *)arg;

	
/*	pthread_mutex_lock(&my_mutex); //lock mutex
	
	pthread_cond_wait(&condSignal,&my_mutex); */
pthread_t tid;

tid = pthread_self();


	sigfillset(&mask);                /* will unblock all signals */  
   pthread_sigmask(SIG_UNBLOCK, &mask, (sigset_t *)0);

   sigwait(&mask, &sig);

printf("Received sig : %d %u\n", sig, (unsigned int)tid);



   switch(sig) {
     case SIGUSR1:
         handlerSig(sig);
         break;
     default:   
         break;
   }
int i=0,count = 0,temp = 0;
sigset_t sigmask;
struct sigaction action;

/* set up signal mask to block all in main thread */
   sigfillset(&sigmask);                /* to turn on all bits */
   pthread_sigmask(SIG_BLOCK, &sigmask, (sigset_t *)0);

   /* set up signal handlers for SIGINT & SIGUSR1 */
   action.sa_flags = 0;
   action.sa_handler = handlerSig;
   sigaction(SIGUSR1, &action, (struct sigaction *)0);
    
	node *tempNode;
	node *newnode;
		
		tempNode = (node *)malloc(sizeof(node));
		newnode = (node *)malloc(sizeof(node));
		newnode = headList;
		
	while(1){

	if(newnode->TCB.threadArrayId == tid){
		printf(" task id : %d\n", newnode->TCB.taskId);
		break;
		}
	newnode = newnode->next;
	}
	
	count = temp = newnode->TCB.taskDuration;
	while(1)
	{
		if(newnode->TCB.taskId != numberOfThreads){
			count--;
		}
		if(count == 0){
			newnode->TCB.remainingTaskDuration = 0;
			break;
		//else{
		//		tskCtrlBloc[i].remaningTaskDuration = temp - count;
		//		break;
		//	}

				
		}
	}

union sigval value;
value.sival_ptr = tempNode;
if(newnode->TCB.remainingTaskDuration == 0){//task completed its execution
printf("New node : %d\n", newnode->TCB.taskId);
tempNode = deleteNode(headList,newnode);//delete the node and invoke scheduler to execute the next task in queue
printList(tempNode);
pthread_sigqueue(tidScheduler, SIGUSR1,value);
//call the scheduler using pthread_sigqueue
//scheduler(tempNode);
}



//	printf( "Hello from thread %d! \n", data->taskId);
	
// 	pthread_mutex_unlock(&my_mutex); //unlock mutex

	usleep(1);
	
 	pthread_exit( NULL );
	
}
Exemple #4
0
int
main(int argc, char **argv) {
	int ret = 0;
	struct activity_stats *activ = NULL;
	struct thread_param *tp = malloc(sizeof(struct thread_param));
	assert(tp);

	struct lvmtscd_params pp = { 0 };

	if (parse_arguments(argc, argv, &pp)) {
		free(tp);
		return 1;
	}

    pp.pp = new_program_params();
    if(!pp.pp) {
        fprintf(stderr, "Out of memory error\n");
        exit(1);
    }

    free(pp.pp->conf_file_path);
    pp.pp->conf_file_path = pp.config_file;

    ret = read_config(pp.pp);
    if(ret) {
        free_program_params(pp.pp);
        exit(1);
    }

    const char *vol_name = get_first_volume_name(pp.pp);

    if(!pp.lv_dev_name)
      asprintf(&pp.lv_dev_name, "/dev/%s/%s", get_volume_vg(pp.pp, vol_name),
          get_volume_lv(pp.pp, vol_name));

	//activ = new_activity_stats_s(1<<10); // assume 2^11 extents (40GiB)
	if(read_activity_stats(&activ, pp.file)) {
		fprintf(stderr, "Can't read \"%s\". Ignoring.\n", pp.file);
		activ = new_activity_stats_s(1<<10); // assume 2^11 extents (40GiB)
	}

	if (pp.daemonize)
		daemonize();

	signal(SIGINT, signalHandler);
	signal(SIGTERM, signalHandler);
	signal(SIGHUP, ignoreHandler);

	tp->activ = activ;
	tp->delay = pp.delay;
	tp->file = pp.file;
	tp->ender = &programEnd;

	pthread_attr_t pt_attr;
	pthread_t thread;

	if (pthread_attr_init(&pt_attr)) {
		fprintf(stderr, "Can't initialize thread attribute\n");
		return 1;
	}

	if(pthread_create(&thread, &pt_attr, &disk_write_worker, tp)) {
		fprintf(stderr, "Can't create thread\n");
		return 1;
	}

	if (collect_trace_points(pp.lv_dev_name,
				 activ,
				 pp.granularity,
				 pp.esize,
				 &programEnd)) {
		fprintf(stderr, "Error while tracing");
		ret = 1;
	}

	fprintf(stderr, "Writing activity stats...");

	union sigval sigArg = {.sival_int=0};
	pthread_sigqueue(thread, SIGHUP, sigArg);

	void *thret;
	pthread_join(thread, &thret);

	destroy_activity_stats(activ);
    free_program_params(pp.pp);

	fprintf(stderr, "done\n");

	return ret;
}