2018-03-07 20:57:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
2018-05-26 01:49:13 +08:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2018-03-07 20:57:14 +08:00
|
|
|
*/
|
|
|
|
|
2018-09-29 15:46:27 +08:00
|
|
|
#ifndef SCHEDULE_H
|
|
|
|
#define SCHEDULE_H
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-06-30 00:17:34 +08:00
|
|
|
#define NEED_RESCHEDULE (1U)
|
|
|
|
#define NEED_OFFLINE (2U)
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-12-20 15:15:20 +08:00
|
|
|
struct sched_object;
|
|
|
|
typedef void (*run_thread_t)(struct sched_object *obj);
|
|
|
|
typedef void (*prepare_switch_t)(struct sched_object *obj);
|
2018-12-20 12:15:25 +08:00
|
|
|
struct sched_object {
|
|
|
|
struct list_head run_list;
|
2018-12-20 15:15:20 +08:00
|
|
|
run_thread_t thread;
|
|
|
|
prepare_switch_t prepare_switch_out;
|
|
|
|
prepare_switch_t prepare_switch_in;
|
2018-12-20 12:15:25 +08:00
|
|
|
};
|
|
|
|
|
2018-06-05 15:25:07 +08:00
|
|
|
struct sched_context {
|
|
|
|
spinlock_t runqueue_lock;
|
|
|
|
struct list_head runqueue;
|
2018-06-29 14:29:34 +08:00
|
|
|
uint64_t flags;
|
2018-12-20 15:15:20 +08:00
|
|
|
struct sched_object *curr_obj;
|
2018-06-05 15:25:07 +08:00
|
|
|
spinlock_t scheduler_lock;
|
|
|
|
};
|
|
|
|
|
2018-03-07 20:57:14 +08:00
|
|
|
void init_scheduler(void);
|
2018-12-20 15:15:20 +08:00
|
|
|
void switch_to_idle(run_thread_t idle_thread);
|
2018-06-20 15:42:52 +08:00
|
|
|
void get_schedule_lock(uint16_t pcpu_id);
|
|
|
|
void release_schedule_lock(uint16_t pcpu_id);
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-06-20 15:42:52 +08:00
|
|
|
void set_pcpu_used(uint16_t pcpu_id);
|
2018-06-25 17:51:00 +08:00
|
|
|
uint16_t allocate_pcpu(void);
|
2018-06-20 15:42:52 +08:00
|
|
|
void free_pcpu(uint16_t pcpu_id);
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-12-20 12:15:25 +08:00
|
|
|
void add_to_cpu_runqueue(struct sched_object *obj, uint16_t pcpu_id);
|
|
|
|
void remove_from_cpu_runqueue(struct sched_object *obj, uint16_t pcpu_id);
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-12-20 13:09:58 +08:00
|
|
|
void make_reschedule_request(uint16_t pcpu_id);
|
2018-12-08 00:30:49 +08:00
|
|
|
int32_t need_reschedule(uint16_t pcpu_id);
|
2018-06-20 15:42:52 +08:00
|
|
|
void make_pcpu_offline(uint16_t pcpu_id);
|
2018-12-08 00:30:49 +08:00
|
|
|
int32_t need_offline(uint16_t pcpu_id);
|
2018-06-02 22:31:58 +08:00
|
|
|
|
2018-03-07 20:57:14 +08:00
|
|
|
void schedule(void);
|
2018-09-29 15:46:27 +08:00
|
|
|
#endif /* SCHEDULE_H */
|
2018-03-07 20:57:14 +08:00
|
|
|
|