Exemple #1
0
void *write_thread(void *_ts) {
	struct ts *ts = _ts;
	struct packet *packet;

	mode_t umask_val = umask(0);
	dir_perm = (0777 & ~umask_val) | (S_IWUSR | S_IXUSR);

	set_thread_name("tsdump-write");
	while ((packet = queue_get(ts->packet_queue))) {
		if (!packet->data_len)
			continue;

		p_dbg1(" - Got packet %d, size: %u, file_time:%lu packet_time:%lu depth:%d\n",
			packet->num, packet->data_len, ALIGN_DOWN(packet->ts.tv_sec, ts->rotate_secs),
			packet->ts.tv_sec, ts->packet_queue->items);

		handle_files(ts, packet);

		if (ts->output_fd > -1) {
			p_dbg2(" - Writing into fd:%d size:%d file:%s\n", ts->output_fd, packet->data_len, ts->output_filename);
			ssize_t written = write(ts->output_fd, packet->data, packet->data_len);
			if (written != packet->data_len) {
				p_err("Can not write data (fd:%d written %zd of %d file:%s)",
					ts->output_fd, written, packet->data_len, ts->output_filename);
			}
		}
		free_packet(packet);
	}
	close_output_file(ts, NO_UNLINK);
	return NULL;
}
Exemple #2
0
int main (int argc, char* const argv[])
{
	int i,j;
	char c;
	nodummy = 0;
    program_name = argv[0];
	double u1, u2, total = 0;
	struct timeval tv;
    
    /* Get the input arguments */
    option_set(argc,argv);
    
    /* Handle the input files */
    handle_files (circuit_name,vectors_name);
    
    
    gettimeofday(&tv,NULL);
   	u1 = tv.tv_sec*1.0e6 + tv.tv_usec;


	/* Read the circuit file and make the structures */
    if (read_circuit (circuit_fd) < 0)
        system_error ("read_circuit");
    fclose (circuit_fd);
    
    if (nog<=0 || nopi<=0 || nopo<=0) {
		fprintf(stderr,"Error in circuit file: #PI=%d, #PO=%d, #GATES=%d\n",nopi,nopo,nog);
		abort();
	}
    
    /* Add a gate for the output stage as you did for the input stage */
    nodummy = add_PO();
    
    /* Compute the levels of the circuit */
    allocate_stacks();
    maxlevel = compute_level();
	place_PO();

	
    printf("the max level = %d\n",maxlevel);
    
    /* Computes the level of each gate */
    allocate_event_list();
    levelize();
    //xfree(event_list); 
    
    gettimeofday(&tv,NULL);
    u2 = tv.tv_sec*1.0e6 + tv.tv_usec;
    
    total=(u2-u1);
    
    printf("Time for construction of data structures: %f usec\n", total);
    total= 0;
    
	printf("opening vectors file= %s\n",vectors_name);
    vectors_fd = fopen (vectors_name, "r");
	if (vectors_fd == NULL)
		system_error ("fopen");
		
	gettimeofday(&tv,NULL);
   	u1 = tv.tv_sec*1.0e6 + tv.tv_usec;
		
	/* Read the vector file and put the input values to the INPUT GATES */
	if (read_vectors (vectors_fd,vectors_name) != 0)
		system_error ("read_vectors");
	//fclose (vectors_fd);  //valgrind mistake
	
	
	
	//logic simulation here
	LUT = create_lut (LUT);
	logic_sim();

	i=0; j=0;
	if(test_name[0]=='\0') {
		while((c=circuit_name[i++])!='\0') {
			if(c=='/') j=0;
			else if(c=='.') break;
			else test_name[j++]=c;
		}
		test_name[j]='\0';
		strcat(test_name,".test");
	}

	gettimeofday(&tv,NULL);
    u2 = tv.tv_sec*1.0e6 + tv.tv_usec;
    
    total=(u2-u1);
    
    printf("Time for logic simulation: %f usec\n", total);
    total= 0;

    //print_logic_sim();
	

	//<----------------------------------------------------------------
	//fault simulation here
	gettimeofday(&tv,NULL);
   	u1 = tv.tv_sec*1.0e6 + tv.tv_usec;	
	
	create_fault_list ();
	//print_fault_list();
	fault_sim();
	
	gettimeofday(&tv,NULL);
    u2 = tv.tv_sec*1.0e6 + tv.tv_usec;
    
    total=(u2-u1);
    
    printf("Time for fault simulation: %f usec\n", total);
    total= 0;
	
	
	
	/*if ( fault_name == NULL ) {
		printf("\nWe are done\n");
		return 0;
	}
	
	printf("opening fault file= %s\n",fault_name);
    vectors_fd = fopen (vectors_name, "r");
	if (vectors_fd == NULL)
		system_error ("fopen"); */
	
	
		
	//	synexeia simulation<-----------------------------------
    
    
    
    printf("\nWe are done\n");
    return 0;
}