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
/**************************************************//**
1
/******************************************************
21
2
Server query execution
23
6
Created 6/5/1996 Heikki Tuuri
24
7
*******************************************************/
31
14
#include "usr0sess.h"
32
15
#include "que0que.h"
34
/**********************************************************************//**
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
/**************************************************************************
35
76
Enqueues a task to server task queue and releases a worker thread, if there
36
77
is a suspended one. */
39
80
srv_que_task_enqueue_low(
40
81
/*=====================*/
41
que_thr_t* thr) /*!< in: query thread */
82
que_thr_t* thr) /* in: query thread */
44
85
ut_ad(mutex_own(&kernel_mutex));
48
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);