utils_gthread: Prevent deadlock caused by wait_idle 41/286741/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Fri, 2 Dec 2022 07:17:32 +0000 (16:17 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Thu, 12 Jan 2023 07:13:27 +0000 (16:13 +0900)
commitcb176af61a52c48c85cce74af397eaedcf65848d
treea303b3b1083a65d0682cbf335b93de669e89d4ba
parentcda120055ddaef4f8f8ad4766829c21b3e81a4a4
utils_gthread: Prevent deadlock caused by wait_idle

 Deadlock situation: Multi-threaded and multi surfaces for each thread

                        T2: call pause_in_idle()->wait_idle()
                            cond_wait() until idle signaled
 T1: call wait_idle()
     wait for lock idle_mutex
                        T2: _thread_idle_cb unlock idle_mutex,
                           set is_idle to TPL_TRUE
                           and wait to lock pause_mutex
 T1: change is_idle to TPL_FALSE
     cond_wait()
                        T2: cannot exit from while loop
                           still cond_wait()

 - is_idle changing should be set TPL_FALSE after cond_wait finished

Change-Id: I44292e486a1b9f686ec28bc0ae10ddedf94a48e3
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_utils_gthread.c