1
/*****************************************************************************
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
*****************************************************************************/
19
/******************************************************
20
Server query execution
22
Created 6/5/1996 Heikki Tuuri
23
*******************************************************/
28
#include "sync0sync.h"
29
#include "os0thread.h"
33
/**************************************************************************
34
Checks if there is work to do in the server task queue. If there is, the
35
thread starts processing a task. Before leaving, it again checks the task
36
queue and picks a new task if any exists. This is called by a SRV_WORKER
40
srv_que_task_queue_check(void)
41
/*==========================*/
46
mutex_enter(&kernel_mutex);
48
thr = UT_LIST_GET_FIRST(srv_sys->tasks);
51
mutex_exit(&kernel_mutex);
56
UT_LIST_REMOVE(queue, srv_sys->tasks, thr);
58
mutex_exit(&kernel_mutex);
64
/**************************************************************************
65
Performs round-robin on the server tasks. This is called by a SRV_WORKER
66
thread every second or so. */
71
/* out: the new (may be == thr) query thread
73
que_thr_t* thr) /* in: query thread */
78
ut_ad(thr->state == QUE_THR_RUNNING);
80
mutex_enter(&kernel_mutex);
82
UT_LIST_ADD_LAST(queue, srv_sys->tasks, thr);
84
new_thr = UT_LIST_GET_FIRST(srv_sys->tasks);
86
mutex_exit(&kernel_mutex);
91
/**************************************************************************
92
Enqueues a task to server task queue and releases a worker thread, if there
93
is a suspended one. */
96
srv_que_task_enqueue_low(
97
/*=====================*/
98
que_thr_t* thr) /* in: query thread */
101
ut_ad(mutex_own(&kernel_mutex));
103
UT_LIST_ADD_LAST(queue, srv_sys->tasks, thr);
105
srv_release_threads(SRV_WORKER, 1);
108
/**************************************************************************
109
Enqueues a task to server task queue and releases a worker thread, if there
110
is a suspended one. */
113
srv_que_task_enqueue(
114
/*=================*/
115
que_thr_t* thr) /* in: query thread */
119
ut_a(0); /* Under MySQL this is never called */
121
mutex_enter(&kernel_mutex);
123
srv_que_task_enqueue_low(thr);
125
mutex_exit(&kernel_mutex);