On Mon, 6 Aug 2012 11:23:57 -0600 Eduardo Silva <[email protected]> wrote:
> not applying: > > Applying: sched: Mark mk_sched_register_thread as static > error: patch failed: src/mk_scheduler.c:161 > error: src/mk_scheduler.c: patch does not apply > Patch failed at 0001 sched: Mark mk_sched_register_thread as static Rebased patch attached. - Lauri
>From 7b428787354ea9f7bd41e6baf7fb9855787a8db8 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <[email protected]> Date: Sun, 17 Jun 2012 17:18:46 +0300 Subject: [PATCH] sched: Mark mk_sched_register_thread as static Signed-off-by: Lauri Kasanen <[email protected]> --- src/include/mk_scheduler.h | 1 - src/mk_scheduler.c | 102 ++++++++++++++++++++++---------------------- 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/src/include/mk_scheduler.h b/src/include/mk_scheduler.h index cd4b939..b3a25f1 100644 --- a/src/include/mk_scheduler.h +++ b/src/include/mk_scheduler.h @@ -76,7 +76,6 @@ extern pthread_key_t worker_sched_node; extern pthread_mutex_t mutex_worker_init; void mk_sched_init(); -int mk_sched_register_thread(int epoll_fd); int mk_sched_launch_thread(int max_events, pthread_t *tout); void *mk_sched_launch_epoll_loop(void *thread_conf); struct sched_list_node *mk_sched_get_handler_owner(void); diff --git a/src/mk_scheduler.c b/src/mk_scheduler.c index bfc4099..ec52132 100644 --- a/src/mk_scheduler.c +++ b/src/mk_scheduler.c @@ -161,6 +161,57 @@ static void mk_sched_thread_lists_init() mk_sched_set_request_list(cs_list); } +/* Register thread information. The caller thread is the thread information's owner */ +static int mk_sched_register_thread(int efd) +{ + unsigned int i; + struct sched_connection *sched_conn, *array; + struct sched_list_node *sl; + static int wid = 0; + + /* + * If this thread slept inside this section, some other thread may touch wid. + * So protect it with a mutex, only one thread may handle wid. + */ + pthread_mutex_lock(&mutex_sched_init); + + sl = &sched_list[wid]; + sl->idx = wid++; + sl->tid = pthread_self(); + + /* + * Under Linux does not exists the difference between process and + * threads, everything is a thread in the kernel task struct, and each + * one has it's own numerical identificator: PID . + * + * Here we want to know what's the PID associated to this running + * task (which is different from parent Monkey PID), it can be + * retrieved with gettid() but Glibc does not export to userspace + * the syscall, we need to call it directly through syscall(2). + */ + sl->pid = syscall(__NR_gettid); + sl->epoll_fd = efd; + + pthread_mutex_unlock(&mutex_sched_init); + + mk_list_init(&sl->busy_queue); + mk_list_init(&sl->av_queue); + + array = mk_mem_malloc_z(sizeof(struct sched_connection) * config->worker_capacity); + + for (i = 0; i < config->worker_capacity; i++) { + sched_conn = &array[i]; + sched_conn->status = MK_SCHEDULER_CONN_AVAILABLE; + sched_conn->socket = -1; + sched_conn->arrive_time = 0; + + mk_list_add(&sched_conn->_head, &sl->av_queue); + } + sl->request_handler = NULL; + + return sl->idx; +} + /* created thread, all this calls are in the thread context */ static void *mk_sched_launch_worker_loop(void *thread_conf) { @@ -213,57 +264,6 @@ static void *mk_sched_launch_worker_loop(void *thread_conf) return 0; } -/* Register thread information. The caller thread is the thread information's owner */ -int mk_sched_register_thread(int efd) -{ - int i; - struct sched_connection *sched_conn, *array; - struct sched_list_node *sl; - static int wid = 0; - - /* - * If this thread slept inside this section, some other thread may touch wid. - * So protect it with a mutex, only one thread may handle wid. - */ - pthread_mutex_lock(&mutex_sched_init); - - sl = &sched_list[wid]; - sl->idx = wid++; - sl->tid = pthread_self(); - - /* - * Under Linux does not exists the difference between process and - * threads, everything is a thread in the kernel task struct, and each - * one has it's own numerical identificator: PID . - * - * Here we want to know what's the PID associated to this running - * task (which is different from parent Monkey PID), it can be - * retrieved with gettid() but Glibc does not export to userspace - * the syscall, we need to call it directly through syscall(2). - */ - sl->pid = syscall(__NR_gettid); - sl->epoll_fd = efd; - - pthread_mutex_unlock(&mutex_sched_init); - - mk_list_init(&sl->busy_queue); - mk_list_init(&sl->av_queue); - - array = mk_mem_malloc_z(sizeof(struct sched_connection) * config->worker_capacity); - - for (i = 0; i < config->worker_capacity; i++) { - sched_conn = &array[i]; - sched_conn->status = MK_SCHEDULER_CONN_AVAILABLE; - sched_conn->socket = -1; - sched_conn->arrive_time = 0; - - mk_list_add(&sched_conn->_head, &sl->av_queue); - } - sl->request_handler = NULL; - - return sl->idx; -} - /* * Create thread which will be listening * for incomings file descriptors -- 1.7.2.1
_______________________________________________ Monkey mailing list [email protected] http://lists.monkey-project.com/listinfo/monkey
