From: Ugo Yu Date: Wed, 5 Jun 2019 12:08:29 +0000 (+0800) Subject: Rename and reset the proirity of HID host thread X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4e25ef13b2;p=android-x86%2Fsystem-bt.git Rename and reset the proirity of HID host thread * Rename the HH event polling thread to bt_hh_thread * HH event polling thread is created by bt_main_thread with RT priority. Lower the thread priority since the tasks in this thread is not timing critical Bug: 131787936 Test: Connect to a HID device Run "adb shell ps -A -T -Z -O rtprio" Change-Id: Ibd983e96bc339393842d4c2e2aa226534095e225 --- diff --git a/btif/co/bta_hh_co.cc b/btif/co/bta_hh_co.cc index 267b8ba92..5a7cad845 100644 --- a/btif/co/bta_hh_co.cc +++ b/btif/co/bta_hh_co.cc @@ -43,6 +43,8 @@ const char* dev_path = "/dev/uhid"; static tBTA_HH_RPT_CACHE_ENTRY sReportCache[BTA_HH_NV_LOAD_MAX]; #endif #define GET_RPT_RSP_OFFSET 9 +#define THREAD_NORMAL_PRIORITY 0 +#define BT_HH_THREAD "bt_hh_thread" void uhid_set_non_blocking(int fd) { int opts = fcntl(fd, F_GETFL); @@ -208,6 +210,17 @@ static void* btif_hh_poll_event_thread(void* arg) { APPL_TRACE_DEBUG("%s: Thread created fd = %d", __func__, p_dev->fd); struct pollfd pfds[1]; + // This thread is created by bt_main_thread with RT priority. Lower the thread + // priority here since the tasks in this thread is not timing critical. + struct sched_param sched_params; + sched_params.sched_priority = THREAD_NORMAL_PRIORITY; + if (sched_setscheduler(gettid(), SCHED_OTHER, &sched_params)) { + APPL_TRACE_ERROR("%s: Failed to set thread priority to normal", __func__); + p_dev->hh_poll_thread_id = -1; + return 0; + } + pthread_setname_np(pthread_self(), BT_HH_THREAD); + pfds[0].fd = p_dev->fd; pfds[0].events = POLLIN;