コード例 #1
0
void DwarfModel::clear_all() {
    clear_pending();
    foreach(Dwarf *d, m_dwarves) {
        delete d;
    }
    m_dwarves.clear();
    m_grouped_dwarves.clear();
    clear();
}
コード例 #2
0
ファイル: stubd.c プロジェクト: senseisimple/emulab-stable
void pop_pending_write(int index)
{
  pending_list * pending = &(rcvdb[index].pending);
  if (pending->is_pending)
  {
    pending->current_index = (pending->current_index + 1) % PENDING_SIZE;
    if (pending->free_index == pending->current_index)
    {
      pending->is_pending = 0;
      clear_pending(index, &write_fds);
    }
    else
    {
      long seconds = pending->writes[pending->current_index].delta / 1000;
      long millis = pending->writes[pending->current_index].delta % 1000;
      pending->deadline.tv_usec += millis * 1000;
      pending->deadline.tv_sec += seconds
        + (pending->deadline.tv_usec / 1000000);
      pending->deadline.tv_usec %= 1000000;
    }
  }
}
コード例 #3
0
ファイル: udp_proxy.c プロジェクト: 0buffer/polarssl
int main( int argc, char *argv[] )
{
    int ret;

    mbedtls_net_context listen_fd, client_fd, server_fd;

    int nb_fds;
    fd_set read_fds;

    mbedtls_net_init( &listen_fd );
    mbedtls_net_init( &client_fd );
    mbedtls_net_init( &server_fd );

    get_options( argc, argv );

    /*
     * Decisions to drop/delay/duplicate packets are pseudo-random: dropping
     * exactly 1 in N packets would lead to problems when a flight has exactly
     * N packets: the same packet would be dropped on every resend.
     *
     * In order to be able to reproduce problems reliably, the seed may be
     * specified explicitly.
     */
    if( opt.seed == 0 )
    {
        opt.seed = (unsigned int) time( NULL );
        mbedtls_printf( "  . Pseudo-random seed: %u\n", opt.seed );
    }

    srand( opt.seed );

    /*
     * 0. "Connect" to the server
     */
    mbedtls_printf( "  . Connect to server on UDP/%s/%s ...",
            opt.server_addr, opt.server_port );
    fflush( stdout );

    if( ( ret = mbedtls_net_connect( &server_fd, opt.server_addr, opt.server_port,
                             MBEDTLS_NET_PROTO_UDP ) ) != 0 )
    {
        mbedtls_printf( " failed\n  ! mbedtls_net_connect returned %d\n\n", ret );
        goto exit;
    }

    mbedtls_printf( " ok\n" );

    /*
     * 1. Setup the "listening" UDP socket
     */
    mbedtls_printf( "  . Bind on UDP/%s/%s ...",
            opt.listen_addr, opt.listen_port );
    fflush( stdout );

    if( ( ret = mbedtls_net_bind( &listen_fd, opt.listen_addr, opt.listen_port,
                          MBEDTLS_NET_PROTO_UDP ) ) != 0 )
    {
        mbedtls_printf( " failed\n  ! mbedtls_net_bind returned %d\n\n", ret );
        goto exit;
    }

    mbedtls_printf( " ok\n" );

    /*
     * 2. Wait until a client connects
     */
accept:
    mbedtls_net_free( &client_fd );

    mbedtls_printf( "  . Waiting for a remote connection ..." );
    fflush( stdout );

    if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd,
                                    NULL, 0, NULL ) ) != 0 )
    {
        mbedtls_printf( " failed\n  ! mbedtls_net_accept returned %d\n\n", ret );
        goto exit;
    }

    mbedtls_printf( " ok\n" );

    /*
     * 3. Forward packets forever (kill the process to terminate it)
     */
    clear_pending();
    memset( dropped, 0, sizeof( dropped ) );

    nb_fds = client_fd.fd;
    if( nb_fds < server_fd.fd )
        nb_fds = server_fd.fd;
    if( nb_fds < listen_fd.fd )
        nb_fds = listen_fd.fd;
    ++nb_fds;

    while( 1 )
    {
        FD_ZERO( &read_fds );
        FD_SET( server_fd.fd, &read_fds );
        FD_SET( client_fd.fd, &read_fds );
        FD_SET( listen_fd.fd, &read_fds );

        if( ( ret = select( nb_fds, &read_fds, NULL, NULL, NULL ) ) <= 0 )
        {
            perror( "select" );
            goto exit;
        }

        if( FD_ISSET( listen_fd.fd, &read_fds ) )
            goto accept;

        if( FD_ISSET( client_fd.fd, &read_fds ) )
        {
            if( ( ret = handle_message( "S <- C",
                                        &server_fd, &client_fd ) ) != 0 )
                goto accept;
        }

        if( FD_ISSET( server_fd.fd, &read_fds ) )
        {
            if( ( ret = handle_message( "S -> C",
                                        &client_fd, &server_fd ) ) != 0 )
                goto accept;
        }
    }

exit:

#ifdef MBEDTLS_ERROR_C
    if( ret != 0 )
    {
        char error_buf[100];
        mbedtls_strerror( ret, error_buf, 100 );
        mbedtls_printf( "Last error was: -0x%04X - %s\n\n", - ret, error_buf );
        fflush( stdout );
    }
#endif

    mbedtls_net_free( &client_fd );
    mbedtls_net_free( &server_fd );
    mbedtls_net_free( &listen_fd );

#if defined(_WIN32)
    mbedtls_printf( "  Press Enter to exit this program.\n" );
    fflush( stdout ); getchar();
#endif

    return( ret != 0 );
}
コード例 #4
0
ファイル: main.c プロジェクト: SixPlusZero/schedNVMe
// Master's main process.
// Each time we take care of the pending 
// queue first, then we focus on the new cmd
static void master_fn(void){

	nvme_register_io_thread();

	// Init pending task
	master_pending.head = NULL;
	master_pending.tail = NULL;
	master_pending.cnt = 0;
	
	// Init task buffer resource
	for (int i = 0; i < QUEUE_NUM; i++){
		tasks[i] = rte_malloc(NULL, sizeof(struct perf_task), 0x200);
		tasks[i]->buf = rte_malloc(NULL, (f_maxsize+1000)*512, 0x200);	
		for (int j = 0; j < ISSUE_BUF_SIZE; j++){
			issue_buf[i].issue_queue[j].io_completed = 1;
			issue_buf[i].issue_queue[j].qid = i;
		}
	}

	//Begin timing.
	uint64_t tsc_start = rte_get_timer_cycles();
	
	uint64_t pos = 0;
	while (pos < f_len){
		//printf("%lu\n", pos);
		clear_issue(-1);		
		clear_pending();
		int target = scheduler(pos);
		if (target >= 0)
		  master_issue(pos, target);
	
		if (target != -2){
			pos += 1;	
			if ((pos % 100000) == 0)
				printf("Master has (allocated && (issued || pending)) %lu commands\n", pos);
		}
	
	}
	printf("Master has issued all of the I/O commands\n");
	
	// Clear all the pending instruction
	while (master_pending.cnt != 0) {
		clear_issue(-1);
		clear_pending();
	}
	
	// Check out all the issued commands
	int flag = 1;
	while (flag){
		flag = 0;
		clear_issue(-1);
		for (int i = 0; i < QUEUE_NUM; i++){
			if (g_master->queue_depth[i]) flag = 1;
		}
	}

	//Stop timing.
	uint64_t tsc_end = rte_get_timer_cycles();
	
	//Get the total time.
	double sec = (tsc_end - tsc_start) / (double)g_tsc_rate;
	
	printf("Stat of pending count: %lu\n", pending_count);

	//Output the result infomation.
	printf("Time: %lf seconds\n", sec);
	printf("Throughput: %lf MB/S\n", (double)f_totalblocks/2048/sec);
	printf("IOPS: %lf /S\n", (double)f_len/sec);
	for (int i = 0; i < QUEUE_NUM; i++){
		rte_free(tasks[i]->buf);
		rte_free(tasks[i]);
	}

	nvme_unregister_io_thread();
}