History

avcodec/executor: remove unused ready callback

Due to the nature of multithreading, using a "ready check" mechanism may introduce a deadlock. For example: Suppose all tasks have been submitted to the executor, and the last thread checks the entire list and finds no ready tasks. It then goes to sleep, waiting for a new task. However, for some multithreading-related reason, a task becomes ready after the check. Since no other thread is aware of this and no new tasks are being added to the executor, a deadlock occurs. In VVC, this function is unnecessary because we use a scoreboard. All tasks submitted to the executor are ready tasks.

Nuo Mi committed 2 years ago

Commit 40a14ef1 parent 8446e273 files · +2 −15Browse files

Unified · Split

3 files
  1. libavcodec/executor.c +2 −4
  2. libavcodec/executor.h +0 −3
  3. libavcodec/vvc/thread.c +0 −8
libavcodec/executor.c+2−4
@@ -79,10 +79,8 @@ static void add_task(FFTask **prev, FFTask *t) · 78 unmodified lines
7979 static int run_one_task(FFExecutor *e, void *lc)
8080 {
8181 FFTaskCallbacks *cb = &e->cb;
82− FFTask **prev;
82+ FFTask **prev = &e->tasks;
8383
84− for (prev = &e->tasks; *prev && !cb->ready(*prev, cb->user_data); prev = &(*prev)->next)
85− /* nothing */;
8684 if (*prev) {
8785 FFTask *t = remove_task(prev, *prev);
8886 if (e->thread_count > 0)
@@ -143,7 +141,7 @@ FFExecutor* ff_executor_alloc(const FFTaskCallbacks *cb, int thread_count) · 54 unmodified lines
143141 {
144142 FFExecutor *e;
145143 int has_lock = 0, has_cond = 0;
146− if (!cb || !cb->user_data || !cb->ready || !cb->run || !cb->priority_higher)
144+ if (!cb || !cb->user_data || !cb->run || !cb->priority_higher)
147145 return NULL;
148146
149147 e = av_mallocz(sizeof(*e));
libavcodec/executor.h+0−3
@@ -42,9 +42,6 @@ typedef struct FFTaskCallbacks { · 41 unmodified lines
4242 // return 1 if a's priority > b's priority
4343 int (*priority_higher)(const FFTask *a, const FFTask *b);
4444
45− // task is ready for run
46− int (*ready)(const FFTask *t, void *user_data);
47−
4845 // run the task
4946 int (*run)(FFTask *t, void *local_context, void *user_data);
5047 } FFTaskCallbacks;
libavcodec/vvc/thread.c+0−8
@@ -372,13 +372,6 @@ static int task_is_stage_ready(VVCTask *t, int add) · 371 unmodified lines
372372 return task_has_target_score(t, stage, score);
373373 }
374374
375−static int task_ready(const FFTask *_t, void *user_data)
376−{
377− VVCTask *t = (VVCTask*)_t;
378−
379− return task_is_stage_ready(t, 0);
380−}
381−
382375 #define CHECK(a, b) \
383376 do { \
384377 if ((a) != (b)) \
@@ -689,7 +682,6 @@ FFExecutor* ff_vvc_executor_alloc(VVCContext *s, const int thread_count) · 304 unmodified lines
689682 s,
690683 sizeof(VVCLocalContext),
691684 task_priority_higher,
692− task_ready,
693685 task_run,
694686 };
695687 return ff_executor_alloc(&callbacks, thread_count);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t