2012-02-05 11:35:58 -05:00
|
|
|
/****************************************************************
|
|
|
|
* *
|
2012-03-24 14:06:46 -04:00
|
|
|
* Copyright 2001, 2012 Fidelity Information Services, Inc *
|
2012-02-05 11:35:58 -05:00
|
|
|
* *
|
|
|
|
* 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"
|
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
#include <signal.h> /* for VSIG_ATOMIC_T */
|
2012-02-05 11:35:58 -05:00
|
|
|
#ifndef __MVS__
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
|
|
|
#ifdef __hpux
|
|
|
|
#include <sys/pstat.h>
|
|
|
|
#else
|
|
|
|
#include "gtm_unistd.h"
|
|
|
|
#endif
|
|
|
|
#else /* __MVS__ */
|
|
|
|
#define CVT_ADDR 0x10 /* -> to CVT */
|
|
|
|
#define OFFSET_IN_CVT_OF_CSD_ADDR 0x294 /* CVT+294 -> CSD */
|
|
|
|
#define OFFSET_IN_CSD_OF_NUM_CPUS_ADDR 0x0a /* CSD+a #cpus online */
|
|
|
|
#define TYPE_OF_NUM_CPUS short
|
|
|
|
#endif
|
|
|
|
#include "send_msg.h"
|
2012-03-24 14:06:46 -04:00
|
|
|
#include "gtmio.h"
|
|
|
|
#include "have_crit.h"
|
|
|
|
#include "eintr_wrappers.h"
|
2012-02-05 11:35:58 -05:00
|
|
|
#include "set_num_additional_processors.h"
|
2012-03-24 14:06:46 -04:00
|
|
|
#ifdef DEBUG
|
|
|
|
#include "io.h"
|
|
|
|
#include "gtm_stdio.h"
|
|
|
|
#include "wcs_sleep.h"
|
|
|
|
#include "wbox_test_init.h"
|
|
|
|
#include "deferred_signal_handler.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
GBLREF int num_additional_processors;
|
2012-02-05 11:35:58 -05:00
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
error_def(ERR_NUMPROCESSORS);
|
2012-02-05 11:35:58 -05:00
|
|
|
|
|
|
|
void set_num_additional_processors(void)
|
|
|
|
{
|
|
|
|
long numcpus;
|
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
# ifdef __hpux
|
2012-02-05 11:35:58 -05:00
|
|
|
struct pst_dynamic psd;
|
2012-03-24 14:06:46 -04:00
|
|
|
DEFER_INTERRUPTS(INTRPT_IN_SET_NUM_ADD_PROCS);
|
|
|
|
# ifdef DEBUG
|
|
|
|
if (gtm_white_box_test_case_enabled
|
|
|
|
&& (WBTEST_SYSCONF_WRAPPER == gtm_white_box_test_case_number))
|
|
|
|
{
|
|
|
|
DBGFPF((stderr, "will sleep indefinitely now\n"));
|
|
|
|
while (TRUE)
|
|
|
|
LONG_SLEEP(60);
|
|
|
|
}
|
|
|
|
# endif
|
2012-02-05 11:35:58 -05:00
|
|
|
if (pstat_getdynamic(&psd, SIZEOF(psd), (size_t)1, 0) == -1)
|
|
|
|
{
|
|
|
|
send_msg(VARLSTCNT(1) ERR_NUMPROCESSORS);
|
|
|
|
numcpus = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
numcpus = psd.psd_proc_cnt;
|
2012-03-24 14:06:46 -04:00
|
|
|
ENABLE_INTERRUPTS(INTRPT_IN_SET_NUM_ADD_PROCS);
|
|
|
|
# else
|
|
|
|
# ifdef __MVS__
|
|
|
|
# ifdef DEBUG
|
|
|
|
DEFER_INTERRUPTS(INTRPT_IN_SET_NUM_ADD_PROCS);
|
|
|
|
if (gtm_white_box_test_case_enabled
|
|
|
|
&& (WBTEST_SYSCONF_WRAPPER == gtm_white_box_test_case_number))
|
|
|
|
{
|
|
|
|
DBGFPF((stderr, "will sleep indefinitely now\n"));
|
|
|
|
while (TRUE)
|
|
|
|
LONG_SLEEP(60);
|
|
|
|
}
|
|
|
|
ENABLE_INTERRUPTS(INTRPT_IN_SET_NUM_ADD_PROCS);
|
|
|
|
# endif
|
|
|
|
numcpus = *(TYPE_OF_NUM_CPUS *)((*(int *)((*(int *)CVT_ADDR) + OFFSET_IN_CVT_OF_CSD_ADDR))
|
|
|
|
+ OFFSET_IN_CSD_OF_NUM_CPUS_ADDR);
|
|
|
|
# else
|
|
|
|
SYSCONF(_SC_NPROCESSORS_ONLN, numcpus);
|
|
|
|
if (numcpus == -1)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
send_msg(VARLSTCNT(1) ERR_NUMPROCESSORS);
|
|
|
|
numcpus = 1;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
num_additional_processors = (int)(numcpus - 1);
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
|
|
|
|