/* scheduler.h - libtf fiber scheduler header * * Copyright (C) 2009-2010 Timo Teräs * All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 or later as * published by the Free Software Foundation. * * See http://www.gnu.org/ for details. */ #ifndef TF_SCHEDULER_H #define TF_SCHEDULER_H #include #include #include #include struct tf_poll_hooks; struct tf_scheduler { struct tf_list_head scheduled_q; struct tf_list_head running_q; struct tf_heap_head heap; void * active_fiber; void * main_fiber; int num_fibers; tf_mtime_t scheduler_time; struct tf_poll_hooks * poller; unsigned long poll_data[2]; }; static inline struct tf_scheduler *tf_scheduler_get_current(void) { extern struct tf_scheduler *__tf_scheduler; TF_BUG_ON(__tf_scheduler == NULL); return __tf_scheduler; } static inline tf_mtime_t tf_scheduler_get_mtime(void) { return tf_scheduler_get_current()->scheduler_time; } struct tf_scheduler *tf_scheduler_create(void); int tf_scheduler_enable(struct tf_scheduler *); void tf_scheduler_disable(void); static inline struct tf_scheduler * tf_scheduler_get(struct tf_scheduler *s) { tf_fiber_get(s); return s; } static inline void tf_scheduler_put(struct tf_scheduler *s) { tf_fiber_put(s); } #endif