Timer-based Task Scheduler

Medium C Concurrency
Solve this problem

Implement a cooperative task scheduler in C using a periodic timer tick. The scheduler maintains task table with function pointers and intervals.

Constraints

  • tick() increments global counter.
  • scheduler() walks tasks.
  • task structure: fn, period, last_run.
  • No preemption.
  • Add and run tasks.
Starter codeC
1typedef void (*taskfn)();2void tick();3void scheduler();