File: gtcml_chkreg.c

package info (click to toggle)
fis-gtm 6.3-014-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 36,680 kB
  • sloc: ansic: 333,039; asm: 5,180; csh: 4,956; sh: 1,924; awk: 291; makefile: 66; sed: 13
file content (86 lines) | stat: -rwxr-xr-x 2,175 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/****************************************************************
 *								*
 * Copyright (c) 2001-2020 Fidelity National Information	*
 * Services, Inc. and/or its subsidiaries. All rights reserved.	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

#include "mdef.h"
#include "gdsroot.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsbt.h"
#include "gdsfhead.h"
#include "filestruct.h"
#include "mlkdef.h"
#include "cmidef.h"
#include "hashtab_mname.h"	/* needed for cmmdef.h */
#include "cmmdef.h"
#include "gt_timer.h"
#include "gtcmlkdef.h"
#include "gtcml.h"

GBLDEF cm_lckblkreg *blkdlist;
GBLREF gd_region *gv_cur_region;

GBLDEF ABS_TIME chkreg_time;

void gtcml_chkreg(void)
{
	cm_lckblkreg	*reg, *reg1;
	gtm_uint64_t	wakeup;

	sys_get_curr_time(&chkreg_time);	/* just once per pass */
	reg1 = reg = blkdlist;

	while (reg)
	{
		gv_cur_region = reg->region->reg;
		if (0 == reg->region->refcnt)
		{
			gtcml_chklck(reg, FALSE);
			assert (0 == reg->lock);
		} else
		{
			/* the following avoids repeated dereferencing on the asumption that a slightly stale value (picked up
			 * outside of LOCK crit) is not a big deal - reconsider on any evidence to the contrary and if so check
			 * mlk_unpend as well
			 */
			wakeup = ((mlk_ctldata *)FILE_INFO(gv_cur_region)->s_addrs.mlkctl)->wakeups;
			assert(wakeup);
			if (reg->region->wakeup < wakeup)
			{
				gtcml_chklck(reg, FALSE);
				reg->pass = CM_BLKPASS;
			} else if (0 == --reg->pass)
			{
				gtcml_chklck(reg, TRUE);
				reg->pass = CM_BLKPASS;
			}
			reg->region->wakeup = wakeup;	/* done for both cases above due to possibility of wakeup rollover */
		}
		if (0 == reg->lock)
		{
			if (reg == blkdlist)
			{
				blkdlist = reg->next;
				free(reg);
				reg = reg1 = blkdlist;
			} else
			{
				reg1->next = reg->next;
				free(reg);
				reg = reg1->next;
			}
		} else
		{
			reg1 = reg;
			reg = reg->next;
		}
	}
}