blob: c7c54cf26a2743d5d7d113b80386a42e0ac988e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
*
* $Id$
*/
#include "db_config.h"
#include "db_int.h"
/* vxworks API to get system clock rate */
int sysClkRateGet (void);
/*
* __os_yield --
* Yield the processor, optionally pausing until running again.
*/
void
__os_yield(env, secs, usecs)
ENV *env;
u_long secs, usecs; /* Seconds and microseconds. */
{
int ticks_delay, ticks_per_second;
COMPQUIET(env, NULL);
/* Don't require the values be normalized. */
for (; usecs >= US_PER_SEC; usecs -= US_PER_SEC)
++secs;
/*
* Yield the processor so other processes or threads can run.
*
* As a side effect, taskDelay() moves the calling task to the end of
* the ready queue for tasks of the same priority. In particular, you
* can yield the CPU to any other tasks of the same priority by
* "delaying" for zero clock ticks.
*
* Never wait less than a tick, if we were supposed to wait at all.
*/
ticks_per_second = sysClkRateGet();
ticks_delay =
secs * ticks_per_second + (usecs * ticks_per_second) / US_PER_SEC;
if (ticks_delay == 0 && (secs != 0 || usecs != 0))
ticks_delay = 1;
(void)taskDelay(ticks_delay);
}
|