hv: sched: simple event implemention

This simple event implemention can only support exclusive waiting
at same time. It mainly used by thread who want to wait for special event
happens.
  Thread A who want to wait for some events calls
	wait_event(struct sched_event *);

  Thread B who can give the event signal calls
	signal_event(struct sched_event *);

Tracked-On: #4329
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Shuo A Liu
2019-12-31 12:55:01 +08:00
committed by wenlingz
parent 5352463ceb
commit 9927b021c5
3 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
#ifndef EVENT_H
#define EVENT_H
#include <spinlock.h>
struct sched_event {
spinlock_t lock;
bool set;
struct thread_object* waiting_thread;
};
void init_event(struct sched_event *event);
void reset_event(struct sched_event *event);
void wait_event(struct sched_event *event);
void signal_event(struct sched_event *event);
#endif /* EVENT_H */