Esempio n. 1
0
main()
{
	if(rr_init())
	{
		perror("rr_init");
		return -1;
	}
	
	for(;;)
	{

		int csr ;
		
		csr = rr_readl(BASE_VUART + UART_REG_DEBUG_CSR);

		if(! (csr & UART_DEBUG_CSR_EMPTY))
		{
			char c = rr_readl(BASE_VUART + UART_REG_DEBUG_R0) & 0xff;
			fprintf(stderr, "%c", c);
		} else
		
		usleep(1000);
	}
	
	return 0;
}
Esempio n. 2
0
    void 
    on_message ( proton::event &e ) 
    {
      log ( "on_message" );

      double receive_timestamp = get_timestamp();

      proton::message& msg = e.message();

      double send_timestamp = msg.body().get<double>();
      double latency = receive_timestamp - send_timestamp;

      fprintf ( output_fp, "latency %.6lf\n", latency );

      if ( ! received )
      {
        rr_init ( & resource_reporter );
      }

      if ( (expected == 0)
           || 
           (expected == -1)
           || 
           (received < expected)
         ) 
      {
        received++;
        if ( ! ( received % report_frequency ) )
        {
          report ( output_fp );
        }

        if (received == expected) 
        {
          log ( "closing receiver and connection." );
          e.receiver().close();
          e.connection().close();
          char filename[1000];
          sprintf ( filename, "/tmp/simple_recv_%d_is_done", getpid() );
          FILE * fp = fopen ( filename, "w" );
          fprintf ( fp, ":-)\n" );
          fclose ( fp );
        }
      }
    }
Esempio n. 3
0
int
main ( int argc, char ** argv )
{
  if ( argc != 3 )
  {
    fprintf ( stderr, "usage: rr PID pause\n" );
    exit ( 1 );
  }

  int pid   = atoi ( argv[1] );
  int pause = atoi ( argv[2] );
  int total_time = 0;

  rr_t rr;

  rr_init ( & rr, pid );

  double cpu;
  int    rss;


  int first_time = 1;

  while ( 1 )
  {
    sleep ( pause );
    total_time += pause;
    rr_report ( & rr, & cpu, & rss );
    if ( first_time )
    {
      fprintf ( stdout, "time\tcpu\trss\n" );
      first_time = 0;
    }

    fprintf ( stdout, 
              "%d\t%lf\t%d\n", 
              total_time,
              cpu, 
              rss 
            );
    fflush ( stdout );
  }
}
Esempio n. 4
0
void 
connection_dispatch ( pn_handler_t *h, pn_event_t *event, pn_event_type_t type )
{
  connection_context_t *cc = connection_context(h);

  switch ( type ) 
  {
    case PN_LINK_REMOTE_OPEN:
      {
        pn_link_t *link = pn_event_link(event);
        if (pn_link_is_receiver(link)) {
          check(cc->recv_link == NULL, "Multiple incomming links on one connection");
          cc->recv_link = link;
          pn_connection_t *conn = pn_event_connection(event);
          pn_list_add(cc->global->active_connections, conn);
          if (cc->global->shutting_down) {
            pn_connection_close(conn);
            break;
          }

          pn_flowcontroller_t *fc = pn_flowcontroller(1024);
          pn_handler_add(h, fc);
          pn_decref(fc);
        }
      }
      break;

    case PN_DELIVERY:
      {
        pn_link_t *recv_link = pn_event_link(event);
        pn_delivery_t *dlv = pn_event_delivery(event);
        if (pn_link_is_receiver(recv_link) && !pn_delivery_partial(dlv)) {
          if (cc->global->received == 0) statistics_start(cc->global->stats);

          size_t encoded_size = pn_delivery_pending(dlv);
          cc->global->encoded_data = ensure_buffer(cc->global->encoded_data, encoded_size,
                                                   &cc->global->encoded_data_size);
          check(cc->global->encoded_data, "decoding buffer realloc failure");

          /*
            If this was the first message received, 
            initialize our reporting.
          */
          if ( ! cc->global->received )
            rr_init ( & cc->global->resource_reporter );

          ssize_t n = pn_link_recv(recv_link, cc->global->encoded_data, encoded_size);
          check(n == (ssize_t) encoded_size, "message data read fail");
          //fprintf ( stderr, "MDEBUG encoded_size == %d\n", encoded_size );
          pn_message_t *msg = cc->global->message;

          int err = pn_message_decode ( msg, cc->global->encoded_data, n );
          check ( err == 0, "message decode error" );

          /* MICK -- annotate! ================================  */
           if ( cc->global->opts->timestamping )
           {
             double message_timestamp;
             if ( get_message_timestamp ( msg, & message_timestamp ) )
             {
               double now = now_timestamp ( );
               cc->global->total_latency += (now - message_timestamp);
             }
             else
             {
               fprintf ( stderr, 
                         "receiver: no timestamp at msg count %d.\n", 
                         cc->global->received 
                       );
               exit ( 1 );
             }
           }
          /* MICK -- end annotate! =============================  */


          cc->global->received++;

          /*---------------------------------------
            Do a report
          ---------------------------------------*/
          if ( ! ( cc->global->received % cc->global->opts->report_frequency ) )
          {
            static bool first_time = true;
            double cpu_percentage;
            int    rss;
            double sslr = rr_seconds_since_last_report ( & cc->global->resource_reporter );
            rr_report ( & cc->global->resource_reporter, & cpu_percentage, & rss );
            double throughput = (double)(cc->global->opts->report_frequency) / sslr;

            if ( first_time )
            {
              if ( cc->global->opts->timestamping )
	      {
		if ( cc->global->opts->print_message_size )
		  fprintf(cc->global->report_fp, "msg_size\trecv_msgs\tcpu\trss\tthroughput\tlatency\n");
		else
		  fprintf(cc->global->report_fp, "recv_msgs\tcpu\trss\tthroughput\tlatency\n");
	      }
	      else
	      {
		if ( cc->global->opts->print_message_size )
		  fprintf(cc->global->report_fp, "msg_size\trecv_msgs\tcpu\trss\tthroughput\n");
		else
		  fprintf(cc->global->report_fp, "recv_msgs\tcpu\trss\tthroughput\n");
	      }
              first_time = false;
            }

            if ( cc->global->opts->timestamping )
            {
              double average_latency = cc->global->total_latency / 
                                       cc->global->opts->report_frequency;
              average_latency *= 1000.0;  // in msec.
              cc->global->total_latency = 0;

              fprintf ( cc->global->report_fp, 
                        "%d\t%lf\t%d\t%lf\t%lf\n", 
                        cc->global->received, 
                        cpu_percentage,
                        rss,
                        throughput,
                        average_latency
                      );
            }
            else
            {
              // was: 
              // "recv_msgs: %10d   cpu: %5.1lf   rss: %6d   throughput: %8.0lf\n"
	      if ( cc->global->opts->print_message_size )
	      {
		fprintf ( cc->global->report_fp, 
			  "%d\t%d\t%lf\t%d\t%lf\n", 
			  cc->global->opts->message_size,
			  cc->global->received, 
			  cpu_percentage,
			  rss,
			  throughput
			);
	      }
	      else
	      {
		fprintf ( cc->global->report_fp, 
			  "%d\t%lf\t%d\t%lf\n", 
			  cc->global->received, 
			  cpu_percentage,
			  rss,
			  throughput
			);
	      }
            }

          }
          pn_delivery_settle(dlv); // move this up

          statistics_msg_received(cc->global->stats, msg);
        }
        if (cc->global->received >= cc->global->opts->msg_count) {
          global_shutdown(cc->global);
        }
      }
      break;

    case PN_CONNECTION_UNBOUND:
      {
        pn_connection_t *conn = pn_event_connection(event);
        pn_list_remove(cc->global->active_connections, conn);
        pn_connection_release(conn);
      }
      break;

    default:
      break;
  }
}
Esempio n. 5
0
void algorithm_init(int n){
	rr_init();
}
Esempio n. 6
0
/**
 * oseacomm_init:
 * @argc: 
 * @argv: 
 * @error: 
 * 
 * Initialize oseacomm so this function have to be called before use oseacomm.
 * 
 * Return value: TRUE on succesful init, otherwise FALSE.
 **/
gboolean oseacomm_init (gint *argc, gchar ***argv, GError **error)
{
	// Initialize RoadRunner
	return rr_init (argc, argv, error);
	
}