コード例 #1
0
ファイル: threadsgi.cpp プロジェクト: EdgarTx/wx
wxMutex::wxMutex()
{
  m_locked = 0;
  p_internal = new wxMutexInternal;
  init_lock(&(p_internal->p_mutex));
}
コード例 #2
0
int main(int argc, char *argv[])
{
    int cpus = sysconf(_SC_NPROCESSORS_ONLN);
    int i;
    int c;

    while ((c = getopt(argc,argv,"C:T:")) != EOF)
        switch (c) {
            case 'C':
                clock_id = atoi(optarg);
                break;

            case 'T':
                alarm(atoi(optarg));
                break;

            default:
                fprintf(stderr, "usage: clocktest [options]\n"
                        "  [-C <clock_id>]              # tested clock, default=%d (CLOCK_REALTIME)\n"
                        "  [-T <test_duration_seconds>] # default=0, so ^C to end\n",
                        CLOCK_REALTIME);
                exit(2);
        }

    mlockall(MCL_CURRENT | MCL_FUTURE);

    signal(SIGALRM, sighand);

    init_lock(&lock);

    per_cpu_data = malloc(sizeof(*per_cpu_data) * cpus);
    if (!per_cpu_data) {
        fprintf(stderr, "%s\n", strerror(ENOMEM));
        exit(1);
    }
    memset(per_cpu_data, 0, sizeof(*per_cpu_data) * cpus);

    for (i = 0; i < cpus; i++) {
        per_cpu_data[i].first_round = 1;
        pthread_create(&per_cpu_data[i].thread, NULL, cpu_thread,
		       (void *)(long)i);
    }

    printf("== Tested clock: %d (", clock_id);
    switch (clock_id) {
        case CLOCK_REALTIME:
            printf("CLOCK_REALTIME");
            break;

        case CLOCK_MONOTONIC:
            printf("CLOCK_MONOTONIC");
            break;

        default:
            printf("<unknown>");
            break;
    }
    printf(")\nCPU      ToD offset [us] ToD drift [us/s]      warps max delta [us]\n"
              "--- -------------------- ---------------- ---------- --------------\n");

    while (1) {
        for (i = 0; i < cpus; i++)
            printf("%3d %20.1f %16.3f %10lu %14.1f\n",
                   i,
                   per_cpu_data[i].offset/1000.0,
                   per_cpu_data[i].drift * 1000000.0,
                   per_cpu_data[i].warps,
                   per_cpu_data[i].max_warp/1000.0);
        usleep(250000);
        printf("\033[%dA", cpus);
    }
}
コード例 #3
0
ファイル: accelerant.cpp プロジェクト: AmirAbrams/haiku
/*! Init primary accelerant */
status_t
radeon_init_accelerant(int device)
{
	TRACE("%s enter\n", __func__);

	status_t status = init_common(device, false);
	if (status != B_OK)
		return status;

	radeon_shared_info &info = *gInfo->shared_info;

	init_lock(&info.accelerant_lock, "radeon hd accelerant");
	init_lock(&info.engine_lock, "radeon hd engine");

	radeon_init_bios(gInfo->rom);

	// probe firmware information
	radeon_gpu_probe();

	// find GPIO pins from AtomBIOS
	gpio_populate();

	// find physical card connectors from AtomBIOS
	status = connector_probe();

	if (status != B_OK) {
		TRACE("%s: falling back to legacy connector probe.\n", __func__);
		status = connector_probe_legacy();
	}

	if (status != B_OK) {
		TRACE("%s: couldn't detect supported connectors!\n", __func__);
		return status;
	}

	// print found connectors
	debug_connectors();

	// setup encoders on each connector if needed
	encoder_init();

	// program external pll clock
	pll_external_init();

	// setup link on any DisplayPort connectors
	dp_setup_connectors();

	// detect attached displays
	status = detect_displays();
	//if (status != B_OK)
	//	return status;

	// print found displays
	debug_displays();

	// create initial list of video modes
	status = create_mode_list();
	//if (status != B_OK) {
	//	radeon_uninit_accelerant();
	//	return status;
	//}

	radeon_gpu_mc_setup();

	// Set up data crunching + irq rings
	radeon_gpu_ring_setup();

	radeon_gpu_ring_boot(RADEON_QUEUE_TYPE_GFX_INDEX);

	TRACE("%s done\n", __func__);
	return B_OK;
}
コード例 #4
0
ファイル: timer.cpp プロジェクト: mallardtheduck/osdev
void init_timer(){
	events = new vector<timer_event*>();
	timers = new map<uint64_t, timer_info*>();
	init_lock(timer_lock);
	sch_new_thread(&timer_thread, NULL);
}
コード例 #5
0
void encoder_integrator_daemon_init() {
  init_lock(&encoder_integrator_daemon_lock, "encoder_integrator_daemon_lock");
  create_thread(encoder_integrator_daemon, STACK_DEFAULT, 0, "encoder_integrator_daemon");
}
コード例 #6
0
ファイル: server.cpp プロジェクト: mailwl/android_server
//--------------------------------------------------------------------------
// debugger remote server - TCP/IP mode
int NT_CDECL main(int argc, char *argv[])
{
#ifdef ENABLE_LOWCNDS
  init_idc();
#endif

  // call the debugger module to initialize its subsystem once
  if ( !init_lock()
    || !init_subsystem()
#ifndef __SINGLE_THREADED_SERVER__
    || !srv_lock_init()
#endif
    )
  {
    lprintf("Could not initialize subsystem!");
    return -1;
  }

  bool reuse_conns = are_broken_connections_supported();
  int port_number = DEBUGGER_PORT_NUMBER;
  lprintf("IDA " SYSTEM SYSBITS " remote debug server(" __SERVER_TYPE__ ") v1.%d. Hex-Rays (c) 2004-2014\n", IDD_INTERFACE_VERSION);
  while ( argc > 1 && (argv[1][0] == '-' || argv[1][0] == '/'))
  {
    switch ( argv[1][1] )
    {
    case 'p':
      port_number = atoi(&argv[1][2]);
      break;
    case 'P':
      server_password = argv[1] + 2;
      break;
    case 'i':
      ipv4_address = argv[1] + 2;
      break;
    case 'v':
      verbose = true;
      break;
    case 'k':
      if ( !reuse_conns )
        error("Sorry, debugger doesn't support reusing broken connections\n");
      keep_broken_connections = true;
      break;
    default:
      error("usage: ida_remote [switches]\n"
               "  -i...  IP address to bind to (default to any)\n"
               "  -v     verbose\n"
               "  -p...  port number\n"
               "  -P...  password\n"
               "%s", reuse_conns ? "  -k     keep broken connections\n" : "");
      break;
    }
    argv++;
    argc--;
  }

#ifndef UNDER_CE
#ifndef __NT__
  signal(SIGHUP, shutdown_gracefully);
#endif
  signal(SIGINT, shutdown_gracefully);
  signal(SIGTERM, shutdown_gracefully);
  signal(SIGSEGV, shutdown_gracefully);
  //  signal(SIGPIPE, SIG_IGN);
#endif

  if ( !init_irs_layer() )
  {
    neterr(NULL, "init_sockets");
  }

  listen_socket = socket(AF_INET, SOCK_STREAM, 0);
  if ( listen_socket == INVALID_SOCKET )
    neterr(NULL, "socket");

  idarpc_stream_t *irs = (idarpc_stream_t *)listen_socket;
  setup_irs(irs);

  struct sockaddr_in sa;
  memset(&sa, 0, sizeof(sa));
  sa.sin_family = AF_INET;
  sa.sin_port   = qhtons(short(port_number));
  if ( ipv4_address != NULL )
    sa.sin_addr.s_addr = inet_addr(ipv4_address);
  if( sa.sin_addr.s_addr == INADDR_NONE )
  {
    lprintf("Cannot parse IP v4 address %s, falling back to INADDR_ANY\n", ipv4_address);
    sa.sin_addr.s_addr = INADDR_ANY;
    ipv4_address = NULL;
  }

  if ( bind(listen_socket, (sockaddr *)&sa, sizeof(sa)) == SOCKET_ERROR )
    neterr(irs, "bind");

  if ( listen(listen_socket, SOMAXCONN) == SOCKET_ERROR )
    neterr(irs, "listen");

  hostent *local_host = gethostbyname("");
  if ( local_host != NULL )
  {
    const char *local_ip;
    if ( ipv4_address != NULL )
      local_ip = ipv4_address;
    else
      local_ip = inet_ntoa(*(struct in_addr *)*local_host->h_addr_list);
    if ( local_host->h_name != NULL && local_ip != NULL )
      lprintf("Host %s (%s): ", local_host->h_name, local_ip);
    else if ( local_ip != NULL )
      lprintf("Host %s: ", local_ip);
  }
  lprintf("Listening on port #%u...\n", port_number);

  while ( true )
  {
    socklen_t salen = sizeof(sa);
    SOCKET rpc_socket = accept(listen_socket, (sockaddr *)&sa, &salen);
    if ( rpc_socket == INVALID_SOCKET )
    {
#ifdef UNDER_CE
      if ( WSAGetLastError() != WSAEINTR )
#else
      if ( errno != EINTR )
#endif
        neterr(irs, "accept");
      continue;
    }
#if defined(__LINUX__) && defined(LIBWRAP)
    const char *p = check_connection(rpc_socket);
    if ( p != NULL )
    {
      fprintf(stderr,
        "ida-server CONNECTION REFUSED from %s (tcp_wrappers)\n", p);
      shutdown(rpc_socket, 2);
      close(rpc_socket);
      continue;
    }
#endif // defined(__LINUX__) && defined(LIBWRAP)

    rpc_server_t *server = new rpc_server_t((idarpc_stream_t *)rpc_socket);
    server->verbose = verbose;
    server->set_debugger_instance(create_debug_session());
    {
#ifdef UNDER_CE
      get_permissions_t all_permissions;
#endif
      handle_session(server);
    }
  }
/* NOTREACHED
  term_lock();
  term_subsystem();
#ifndef __SINGLE_THREADED_SERVER__
  qmutex_free(g_lock);
#endif
*/
}