Skip to content

Reduce CPU usage in several threads to zero when idle using semaphore + atomic #152

@Morcules

Description

@Morcules

Currently, threads in process_packets.c and execute_packet_callback.c busy wait on the queue, resulting in ~50% CPU usage even when there is no network traffic.

Proposed change:
Replace busy wait polling with a blocking queue implementation that uses:

  • Atomic operations (<stdatomic.h>) for lock-free head/tail management
  • A POSIX semaphore (sem_t from <semaphore.h>) to block consumer threads efficiently when the queue is empty

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions