void GKI_init(void) { pthread_mutexattr_t attr; tGKI_OS *p_os; memset (&gki_cb, 0, sizeof (gki_cb)); gki_buffer_init(); gki_timers_init(); gki_cb.com.OSTicks = (UINT32) times(0); pthread_mutexattr_init(&attr); #ifndef __CYGWIN__ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); #endif p_os = &gki_cb.os; pthread_mutex_init(&p_os->GKI_mutex, &attr); /* pthread_mutex_init(&GKI_sched_mutex, NULL); */ #if (GKI_DEBUG == TRUE) pthread_mutex_init(&p_os->GKI_trace_mutex, NULL); #endif /* pthread_mutex_init(&thread_delay_mutex, NULL); */ /* used in GKI_delay */ /* pthread_cond_init (&thread_delay_cond, NULL); */ /* Initialiase GKI_timer_update suspend variables & mutexes to be in running state. * this works too even if GKI_NO_TICK_STOP is defined in btld.txt */ p_os->no_timer_suspend = GKI_TIMER_TICK_RUN_COND; pthread_mutex_init(&p_os->gki_timer_mutex, NULL); #ifndef NO_GKI_RUN_RETURN pthread_cond_init(&p_os->gki_timer_cond, NULL); #endif }
void GKI_init(void) { pthread_mutexattr_t attr; tGKI_OS *p_os; memset (&gki_cb, 0, sizeof (gki_cb)); gki_buffer_init(); gki_timers_init(); alarm_service_init(); gki_cb.com.OSTicks = (UINT32) times(0); pthread_mutexattr_init(&attr); #ifndef __CYGWIN__ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); #endif p_os = &gki_cb.os; pthread_mutex_init(&p_os->GKI_mutex, &attr); /* pthread_mutex_init(&GKI_sched_mutex, NULL); */ #if (GKI_DEBUG == TRUE) pthread_mutex_init(&p_os->GKI_trace_mutex, NULL); #endif /* pthread_mutex_init(&thread_delay_mutex, NULL); */ /* used in GKI_delay */ /* pthread_cond_init (&thread_delay_cond, NULL); */ struct sigevent sigevent; memset(&sigevent, 0, sizeof(sigevent)); sigevent.sigev_notify = SIGEV_THREAD; sigevent.sigev_notify_function = (void (*)(union sigval))bt_alarm_cb; sigevent.sigev_value.sival_ptr = NULL; if (timer_create(CLOCK_REALTIME, &sigevent, &posix_timer) == -1) { ALOGE("%s unable to create POSIX timer: %s", __func__, strerror(errno)); timer_created = false; } else { timer_created = true; } }