Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 2caaa0bc rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Small corrections

parent 1d6a4b4b
Branches
Étiquettes
1 requête de fusion!67Resolve "Thread pool"
...@@ -147,8 +147,7 @@ sdl_thread__(struct poller_thread_arg *arg) ...@@ -147,8 +147,7 @@ sdl_thread__(struct poller_thread_arg *arg)
LOG_INFO_SCT("WINDOW", "%s", "Started SDL thread"); LOG_INFO_SCT("WINDOW", "%s", "Started SDL thread");
loop: loop:
if (SDL_PollEvent(&event)) SDL_WaitEvent(&event);
sched_yield();
switch (event.type) { switch (event.type) {
case SDL_QUIT: case SDL_QUIT:
...@@ -207,6 +206,8 @@ loop: ...@@ -207,6 +206,8 @@ loop:
SDL_GL_SwapWindow((SDL_Window *) sdl2->window); SDL_GL_SwapWindow((SDL_Window *) sdl2->window);
redraw = 0; redraw = 0;
} }
sched_yield();
goto loop; /* A loop without indentation. */ goto loop; /* A loop without indentation. */
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#endif #endif
#ifdef TWO_LEVEL #ifdef TWO_LEVEL
#define MTHREAD_LWP 4 #define MTHREAD_LWP 3
#else #else
#define MTHREAD_LWP 1 #define MTHREAD_LWP 1
#endif #endif
...@@ -157,6 +157,8 @@ mthread_work_take(mthread_virtual_processor_t *vp) ...@@ -157,6 +157,8 @@ mthread_work_take(mthread_virtual_processor_t *vp)
void void
__mthread_yield(mthread_virtual_processor_t *vp) __mthread_yield(mthread_virtual_processor_t *vp)
{ {
sched_yield();
struct mthread_s *current = (struct mthread_s *)vp->current; struct mthread_s *current = (struct mthread_s *)vp->current;
struct mthread_s *next = mthread_remove_first(&(vp->ready_list)); struct mthread_s *next = mthread_remove_first(&(vp->ready_list));
...@@ -198,7 +200,6 @@ __mthread_yield(mthread_virtual_processor_t *vp) ...@@ -198,7 +200,6 @@ __mthread_yield(mthread_virtual_processor_t *vp)
mthread_spinlock_unlock(vp->p); mthread_spinlock_unlock(vp->p);
vp->p = NULL; vp->p = NULL;
} }
} }
static void static void
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <sqlite3.h> #include <sqlite3.h>
#include <sched.h>
#include <assert.h> #include <assert.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <errno.h> #include <errno.h>
...@@ -479,9 +480,9 @@ failure: ...@@ -479,9 +480,9 @@ failure:
} }
if (host) if (host)
LOG_ERROR_SCT("NETWORK", "Listening on %s:%s", host, port); LOG_INFO_SCT("NETWORK", "Listening on %s:%s", host, port);
else else
LOG_ERROR_SCT("NETWORK", "Listening on port %s", port); LOG_INFO_SCT("NETWORK", "Listening on port %s", port);
return fd; return fd;
} }
......
...@@ -178,6 +178,7 @@ try_later: ...@@ -178,6 +178,7 @@ try_later:
LOG_ERROR("%s", "Failed to get the head of the input list"); LOG_ERROR("%s", "Failed to get the head of the input list");
end_loop: end_loop:
mthread_yield();
sleep(1); sleep(1);
} }
......
...@@ -29,7 +29,6 @@ int ...@@ -29,7 +29,6 @@ int
lkt_th_new(struct poller_thread *th, unsigned int init_sizes, lkt_th_new(struct poller_thread *th, unsigned int init_sizes,
void *(*func)(struct poller_thread_arg *), void *args) void *(*func)(struct poller_thread_arg *), void *args)
{ {
int ret = 1;
mthread_mutex_t mtx1 = MTHREAD_MUTEX_INITIALIZER; mthread_mutex_t mtx1 = MTHREAD_MUTEX_INITIALIZER;
mthread_mutex_t mtx2 = MTHREAD_MUTEX_INITIALIZER; mthread_mutex_t mtx2 = MTHREAD_MUTEX_INITIALIZER;
struct poller_thread th_ = { struct poller_thread th_ = {
...@@ -53,16 +52,16 @@ lkt_th_new(struct poller_thread *th, unsigned int init_sizes, ...@@ -53,16 +52,16 @@ lkt_th_new(struct poller_thread *th, unsigned int init_sizes,
__args->arg = args; __args->arg = args;
__args->arg->self = th; __args->arg->self = th;
ret = mthread_create(&(th->th), NULL, __start, __args); if(!mthread_create(&(th->th), NULL, __start, __args)) {
LOG_INFO_SCT("THREAD", "%s", "Create a new poller thread");
if (ret) return 0;
goto end; }
end: else {
fprintf(stderr, " %c lkt_th_new: %s\n", error:
ret ? '!' : '*', LOG_ERROR_SCT("THREAD", "%s", "Failed to create a poller thread");
ret ? "Failed to create a new thread" : "Created a new thread"); return 1;
return ret; }
out_of_memory: out_of_memory:
LOG_ERROR_SCT("MEMORY", "%s", "Out of memory"); LOG_ERROR_SCT("MEMORY", "%s", "Out of memory");
...@@ -70,8 +69,7 @@ out_of_memory: ...@@ -70,8 +69,7 @@ out_of_memory:
free((void *) th_.input_cells); free((void *) th_.input_cells);
if (th_.output_cells) if (th_.output_cells)
free((void *) th_.output_cells); free((void *) th_.output_cells);
ret = errno = ENOMEM; goto error;
goto end;
} }
int int
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter