Skip to content

A potential deadlock error due to cyclic order on lock acqusitions #203

@jenny-cheung

Description

@jenny-cheung

pthread_mutex_lock(&s->workq_lock);

int aml_active_sched_num_tasks(struct aml_sched *sched)
{
	...;
	// Lock queues to get the right count.
	pthread_mutex_lock(&s->workq_lock);
	pthread_mutex_lock(&s->doneq_lock);
	...;
	pthread_mutex_unlock(&s->workq_lock);
	pthread_mutex_unlock(&s->doneq_lock);
	return n;
}
// Wait for any task when calling thread is responsible for progress.
struct aml_task *aml_active_sched_wait_any(struct aml_sched_data *data)
{
	...;
	pthread_mutex_lock(&(sched->doneq_lock));
	...;

	pthread_mutex_lock(&(sched->workq_lock));
	...;

	pthread_mutex_unlock(&(sched->workq_lock));
found_in_doneq:
	pthread_mutex_unlock(&(sched->doneq_lock));
	return task;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions