diff --git a/src/main/server.c b/src/main/server.c index d7c00eed3905441f42d2eee46d4bd07861ed1c71..3c12393aae955f437550038bf0100c1972d3d929 100644 --- a/src/main/server.c +++ b/src/main/server.c @@ -57,7 +57,7 @@ main(int argc, char *argv[]) normal_launch: LOG_INFO("Lektor launched by user %s (shell: %s, home: %s)", pw->pw_name, pw->pw_shell, pw->pw_dir); - // mthread_init(); + mthread_init(); return lkt_listen(); } diff --git a/src/mthread/mthread.c b/src/mthread/mthread.c index 7f9dae67d25ae2a7e2469a2e98ebb680397dd3c7..47fff88c85c388168c910d3ae3025d5959d91043 100644 --- a/src/mthread/mthread.c +++ b/src/mthread/mthread.c @@ -2,17 +2,7 @@ #include <sched.h> #include <string.h> -#define TWO_LEVEL - -#ifdef TWO_LEVEL -#include <pthread.h> -#endif - -#ifdef TWO_LEVEL -#define MTHREAD_LWP 3 -#else #define MTHREAD_LWP 1 -#endif static mthread_virtual_processor_t virtual_processors[MTHREAD_MAX_VIRUTAL_PROCESSORS]; static mthread_list_t joined_list; @@ -134,26 +124,6 @@ mthread_mctx_swap(struct mthread_s *cur_mctx, struct mthread_s *new_mctx) return 0; } -static struct mthread_s * -mthread_work_take(mthread_virtual_processor_t *vp) -{ - int i; - struct mthread_s *tmp = NULL; - for (i = 0; i < MTHREAD_LWP; i++) { - tmp = NULL; - if (vp != &(virtual_processors[i])) { - if (virtual_processors[i].ready_list.first != NULL) - tmp = mthread_remove_first(&(virtual_processors[i].ready_list)); - } - if (tmp != NULL) { - LOG_INFO_SCT("LOAD BALANCE", "Work %p from %d to %d", (void *) tmp, i, vp->rank); - return tmp; - } - } - sched_yield(); - return tmp; -} - void __mthread_yield(mthread_virtual_processor_t *vp) { @@ -162,11 +132,6 @@ __mthread_yield(mthread_virtual_processor_t *vp) struct mthread_s *current = (struct mthread_s *)vp->current; struct mthread_s *next = mthread_remove_first(&(vp->ready_list)); -#ifdef TWO_LEVEL - if (next == NULL) - next = mthread_work_take(vp); -#endif - if (vp->resched != NULL) { LOG_INFO_SCT("SCHEDULER", "Insert %p in ready list of %d", (void *) vp->resched, vp->rank); mthread_insert_last((struct mthread_s *)vp->resched, &(vp->ready_list)); @@ -224,18 +189,10 @@ mthread_idle_task(void *arg) not_implemented(); } -#ifdef TWO_LEVEL -static pthread_key_t lwp_key; -#endif - mthread_virtual_processor_t * mthread_get_vp() { -#ifdef TWO_LEVEL - return pthread_getspecific(lwp_key); -#else return &(virtual_processors[0]); -#endif } int @@ -281,13 +238,7 @@ mthread_init_lib(long i) mthread_init_thread(current); current->__start_routine = mthread_main; current->stack = NULL; -#ifdef TWO_LEVEL - pthread_key_create(&lwp_key, NULL); -#endif } -#ifdef TWO_LEVEL - pthread_setspecific(lwp_key, &(virtual_processors[i])); -#endif mthread_init_vp(&(virtual_processors[i]), mctx, mctx, i); mthread_mctx_set(mctx, mthread_idle_task, stack, MTHREAD_DEFAULT_STACK, &(virtual_processors[i])); @@ -298,14 +249,6 @@ mthread_init_lib(long i) virtual_processors[i].current = current; } -static void * -mthread_lwp_start(void *arg) -{ - mthread_init_lib((long)arg); - not_implemented(); - return NULL; -} - static void mthread_start_thread(void *arg) { @@ -325,34 +268,8 @@ mthread_start_thread(void *arg) static inline void __mthread_lib_init() { -#ifdef TWO_LEVEL - do { - long i; - for (i = 0; i < MTHREAD_LWP; i++) - virtual_processors[i].state = 0; - } while (0); -#endif mthread_init_lib(0); virtual_processors[0].state = 1; -#ifdef TWO_LEVEL - do { - long i; - long j; - int done = 0; - for (i = 1; i < MTHREAD_LWP; i++) { - pthread_t pid; - pthread_create(&pid, NULL, mthread_lwp_start, (void *)i); - } - while (done == 0) { - done = 1; - sched_yield(); - for (j = 0; j < MTHREAD_LWP; j++) { - if (virtual_processors[j].state == 0) - done = 0; - } - } - } while (0); -#endif LOG_INFO_SCT("MThread", "%s", "library started"); }