2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: JRD Access Method
|
2003-11-07 09:06:35 +01:00
|
|
|
* MODULE: sch.cpp
|
2001-05-23 15:26:42 +02:00
|
|
|
* DESCRIPTION: Voluntary thread scheduler
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Interbase Public
|
|
|
|
* License Version 1.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy
|
|
|
|
* of the License at http://www.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
2002-10-30 07:40:58 +01:00
|
|
|
*
|
|
|
|
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
|
|
|
|
*
|
2001-05-23 15:26:42 +02:00
|
|
|
*/
|
|
|
|
|
2001-07-29 19:42:23 +02:00
|
|
|
#include "firebird.h"
|
2004-04-29 00:43:34 +02:00
|
|
|
#include <stdio.h>
|
2001-05-23 15:26:42 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "../jrd/common.h"
|
2008-01-16 10:48:41 +01:00
|
|
|
#include "../jrd/ThreadStart.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../jrd/isc.h"
|
2003-11-08 17:40:17 +01:00
|
|
|
#include "../jrd/ibase.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../jrd/gds_proto.h"
|
|
|
|
#include "../jrd/isc_s_proto.h"
|
|
|
|
#include "../jrd/sch_proto.h"
|
2004-05-18 00:30:09 +02:00
|
|
|
#include "../jrd/thread_proto.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../jrd/err_proto.h"
|
|
|
|
#include "../jrd/iberr_proto.h"
|
|
|
|
#include "../jrd/gdsassert.h"
|
2002-10-25 18:28:17 +02:00
|
|
|
#include "../jrd/os/thd_priority.h"
|
2003-12-14 05:33:51 +01:00
|
|
|
#include "../common/classes/locks.h"
|
2008-01-23 16:52:40 +01:00
|
|
|
#include "../common/classes/init.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
#ifdef WIN_NT
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-01-26 14:17:19 +01:00
|
|
|
static FB_THREAD_ID thread_id = 0;
|
2008-01-23 16:52:40 +01:00
|
|
|
static Firebird::GlobalPtr<Firebird::Mutex> thread_mutex;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
int API_ROUTINE gds__thread_enable(int enable_flag)
|
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* g d s _ $ t h r e a d _ e n a b l e
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* Check-in with thread traffic cop.
|
|
|
|
*
|
|
|
|
**************************************/
|
|
|
|
|
2008-01-16 10:48:41 +01:00
|
|
|
return true;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-16 10:48:41 +01:00
|
|
|
void API_ROUTINE gds__thread_enter()
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* g d s _ $ t h r e a d _ e n t e r
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* Check-in with thread traffic cop.
|
|
|
|
*
|
|
|
|
**************************************/
|
|
|
|
|
2008-01-26 14:17:19 +01:00
|
|
|
thread_mutex->enter();
|
|
|
|
fb_assert(!thread_id);
|
|
|
|
thread_id = getThreadId();
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-16 10:48:41 +01:00
|
|
|
void API_ROUTINE gds__thread_exit()
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* g d s _ $ t h r e a d _ e x i t
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* Check-out with thread traffic cop.
|
|
|
|
*
|
|
|
|
**************************************/
|
|
|
|
|
2008-01-26 14:17:19 +01:00
|
|
|
fb_assert(thread_id == getThreadId());
|
|
|
|
thread_id = 0;
|
|
|
|
thread_mutex->leave();
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|