Example #1
0
void print_elem(void *q_elem)
{
	struct elem_hist *e = (struct elem_hist *)q_elem;

	fprintf(stdout,"@@@@@\nsizeof() = %ld [o]\n", get_size_elem(q_elem));
	fprintf(stdout, "+++++\nadr : %p\n+++++\nurl : %s\nipcli : %s\ndate : %s\nstaterr : %d\nq_next : %p\n@@@@@\n", 
			(void *)e, e->q_url, e->q_ipcli, e->q_date, e->q_staterr, (void *)(e->q_next));
}
Example #2
0
int push(void *q_this, void *q_elem)
{
	int size_elem = 0;
	void *q_elem_tmp = NULL;

	if((q_this != NULL) && (q_elem != NULL))
	{
		size_elem = get_size_elem(q_elem);

		// Si la somme de la taille totale de la file et du nouvel élément est
		// supérieur à la taille maximum authorisée, alors le plus ancien
		// élément.

		while((((struct queue_hist *)q_this)->get_size_queue(q_this) + size_elem) > 
			((struct queue_hist *)q_this)->get_max_size_queue(q_this))
		{
			fprintf(stdout, "\n\nTaille trop petite\n\n");
			((struct queue_hist *)q_this)->pop(q_this);
		}

		// Ensuite, on ajoute le nouvel élément en queue de file.
		((struct queue_hist *)q_this)->nb_elem++;
		((struct queue_hist *)q_this)->size_queue += size_elem;

		// La file est vide.
		if((((struct queue_hist *)q_this)->first_elem == NULL) && 
			   (((struct queue_hist *)q_this)->last_elem == NULL))
		{
			((struct queue_hist *)q_this)->first_elem = q_elem;
			((struct queue_hist *)q_this)->last_elem = q_elem;
		}
		// La file n'est pas vide.
		else
		{
			q_elem_tmp = ((struct queue_hist *)q_this)->last_elem;
			((struct queue_hist *)q_this)->last_elem = q_elem;
			((struct elem_hist *)q_elem)->q_next = q_elem_tmp;
		}

		return EXIT_SUCCESS;	
	}

	return -1;
}
Example #3
0
// read partitions parameters
int read_partitions(){

	int partitions_id[MAX_PARTITIONS];

	int z;
	for (z=0; z<MAX_PARTITIONS; z++){
		partitions_id[z]=0;
	}

	debug_printf("\n*********** READ PARTITIONS **********\n");
	
	xmlChar * xpathExpr = BAD_CAST "//partition";

	if (getNode(xpathExpr,&xpathObj) != 0){
		return -1;
	}
	
	nb_partitions = xpathObj->nodesetval->nodeNr;
	strcpy(macro_values[POK_CONFIG_NB_PARTITIONS],number_to_string[nb_partitions]);
	macro_enabled[POK_CONFIG_NB_PARTITIONS] = TRUE;

	debug_printf("Partition number %s\n", macro_values[POK_CONFIG_NB_PARTITIONS]);

	xmlChar *attr_name = "id";
	xmlChar *id;
	char expression[100];
	char base_expression[40];
	//char *expression;
	//char *base_expression;

	int partition_id;
	int user_partition_id;
	int partition_core_id;

	int i;
	for (i=0; i<nb_partitions; i++){

		
		// read user partition id
		xmlNodePtr partition = 	xpathObj->nodesetval->nodeTab[i];			
		id = xmlGetProp(partition,attr_name);
		user_partition_id = atoi(id);
		debug_printf("integer id %d\n",user_partition_id);
		
		if (partitions_id[user_partition_id]){
			printf("ERROR: user_partition_id %d already defined \n",user_partition_id);
			return -1;
		}else{
			partitions_id[user_partition_id]=1;
		}

		
		// set the partition name
		partition_id = i;
		partitions[partition_id].user_partition_id = user_partition_id;
		strcpy(base_expression,"");
		strcat(base_expression, "//partition[@id=\"");
		strcat(base_expression, id);
		strcat(base_expression, "\"]");
		debug_printf("expression: %s\n",base_expression);
		strcpy(partitions[partition_id].part_name,"part");
		strcat(partitions[partition_id].part_name,number_to_string[partition_id+1]);
		debug_printf("part name %s\n", partitions[partition_id].part_name);
	
		// looking for scheduler element
		if (get_scheduler_elem(base_expression, partition_id, xpathObj) != 0){
			return -1;
		}
		if (get_threads_elem(base_expression,partition_id) != 0){
			return -1;
		}

		strcpy(macro_values[POK_CONFIG_PRIORITY_LEVELS], number_to_string[nb_priority_levels]);
		debug_printf("Priority_levels value %s\n", macro_values[POK_CONFIG_PRIORITY_LEVELS]);	

		// looking for size element
		if (get_size_elem(base_expression, partition_id) != 0){
			return -1;
		}

		// looking for loadaddr element
		if (get_loadaddr_elem(base_expression, partition_id) != 0){
			return -1;
		}

		// looking for slot element
		if (get_slots_elem(base_expression, partition_id) != 0){
			return -1;
		}
	
		// looking for nb_asynch_events element
		if (get_asynch_events_elem (base_expression, partition_id) != 0){
			return -1;
		}

		// looking for blackboards element
		if (get_blackboards_elem(base_expression, partition_id) != 0){
			return -1;
		}
		
		// looking for buffers/max_messages element
		if (get_buffers_elem(base_expression, partition_id) != 0){
			return -1;
		}
		
		// check if the nuber of threads are enaugh or not
		if ( (partitions[partition_id].nb_events_blackb_buffers *2) > partitions[partition_id].nb_of_threads ){
			printf("ERROR: Not enought threads\n");
			return -1;
		}
	}// for

//	if (nb_slots > nb_partitions){
	int k;
	for (k=0; k<nb_partitions; k++){
		partitions[k].period = major_frame / partitions[k].nb_slots;
		debug_printf("partition period %d\n",partitions[k].period);
	}
//	}

	strcpy(macro_values[POK_CONFIG_SCHEDULING_NBSLOTS],number_to_string[nb_slots]);
	macro_enabled[POK_CONFIG_SCHEDULING_NBSLOTS] = TRUE;

	return 0;
}