1 /******************************************************
6 Created 6/5/1996 Heikki Tuuri
7 *******************************************************/
12 #include "sync0sync.h"
13 #include "os0thread.h"
17 /**************************************************************************
18 Checks if there is work to do in the server task queue. If there is, the
19 thread starts processing a task. Before leaving, it again checks the task
20 queue and picks a new task if any exists. This is called by a SRV_WORKER
24 srv_que_task_queue_check(void)
25 /*==========================*/
30 mutex_enter(&kernel_mutex
);
32 thr
= UT_LIST_GET_FIRST(srv_sys
->tasks
);
35 mutex_exit(&kernel_mutex
);
40 UT_LIST_REMOVE(queue
, srv_sys
->tasks
, thr
);
42 mutex_exit(&kernel_mutex
);
48 /**************************************************************************
49 Performs round-robin on the server tasks. This is called by a SRV_WORKER
50 thread every second or so. */
55 /* out: the new (may be == thr) query thread
57 que_thr_t
* thr
) /* in: query thread */
62 ut_ad(thr
->state
== QUE_THR_RUNNING
);
64 mutex_enter(&kernel_mutex
);
66 UT_LIST_ADD_LAST(queue
, srv_sys
->tasks
, thr
);
68 new_thr
= UT_LIST_GET_FIRST(srv_sys
->tasks
);
70 mutex_exit(&kernel_mutex
);
75 /**************************************************************************
76 Enqueues a task to server task queue and releases a worker thread, if there
77 is a suspended one. */
80 srv_que_task_enqueue_low(
81 /*=====================*/
82 que_thr_t
* thr
) /* in: query thread */
85 ut_ad(mutex_own(&kernel_mutex
));
87 UT_LIST_ADD_LAST(queue
, srv_sys
->tasks
, thr
);
89 srv_release_threads(SRV_WORKER
, 1);
92 /**************************************************************************
93 Enqueues a task to server task queue and releases a worker thread, if there
94 is a suspended one. */
99 que_thr_t
* thr
) /* in: query thread */
103 ut_a(0); /* Under MySQL this is never called */
105 mutex_enter(&kernel_mutex
);
107 srv_que_task_enqueue_low(thr
);
109 mutex_exit(&kernel_mutex
);