/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* 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 is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nspr.h"
#include "plgetopt.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int _debug_on = 0;
#ifdef XP_MAC
#include "prlog.h"
#include "prsem.h"
extern void SetupMacPrintfLog(char *logFile);
#else
#endif
static void nop(int a, int b, int c)
{
}
static void LocalProcedureCall(void)
{
PRInt32 i;
for (i = 0; i < count; i++) {
nop(i, i, 5);
}
}
static void DLLProcedureCall(void)
{
PRInt32 i;
for (i = 0; i < count; i++) {
}
}
static void Now(void)
{
PRInt32 i;
for (i = 0; i < count; i++) {
}
}
static void Interval(void)
{
PRInt32 i;
for (i = 0; i < count; i++) {
time = PR_IntervalNow();
}
}
static void IdleLock(void)
{
PRInt32 i;
for (i = 0; i < count; i++) {
}
}
static void IdleMonitor(void)
{
PRInt32 i;
for (i = 0; i < count; i++) {
}
}
static void IdleCMonitor(void)
{
PRInt32 i;
for (i = 0; i < count; i++) {
PR_CEnterMonitor((void*)7);
PR_CExitMonitor((void*)7);
}
}
/************************************************************************/
{
}
static void CDThread(void)
{
PRInt32 i;
/*
* Cannot create too many threads
*/
if (num_threads > 1000)
num_threads = 1000;
for (i = 0; i < num_threads; i++) {
dull, 0,
0);
if (NULL == t) {
} else {
DPRINTF(("CDThread: created thread %3d \n",i));
}
PR_Sleep(0);
}
}
static int alive;
static int cxq;
{
PRInt32 i, n;
n = count / 2;
for (i = 0; i < n; i++) {
while (cxq == 0) {
DPRINTF(("CXReader: thread = 0x%lx waiting\n",
PR_GetCurrentThread()));
}
--cxq;
}
--alive;
}
{
PRInt32 i, n;
n = count / 2;
for (i = 0; i < n; i++) {
while (cxq == 1) {
DPRINTF(("CXWriter: thread = 0x%lx waiting\n",
PR_GetCurrentThread()));
}
++cxq;
}
--alive;
}
{
alive = 2;
cxq = 0;
CXReader, 0,
0);
} else {
DPRINTF(("ContextSwitch: created %s thread = 0x%lx\n",
(scope1 == PR_GLOBAL_THREAD ?
"PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD"),
t1));
}
CXWriter, 0,
0);
} else {
DPRINTF(("ContextSwitch: created %s thread = 0x%lx\n",
(scope2 == PR_GLOBAL_THREAD ?
"PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD"),
t2));
}
/* Wait for both of the threads to exit */
while (alive) {
}
}
static void ContextSwitchUU(void)
{
}
static void ContextSwitchUK(void)
{
}
static void ContextSwitchKU(void)
{
}
static void ContextSwitchKK(void)
{
}
/************************************************************************/
{
PRInt32 i, n;
n = count / 2;
for (i = 0; i < n; i++) {
DPRINTF(("SemaThread: thread = 0x%lx waiting on sem = 0x%lx\n",
PR_GetCurrentThread(), sem[0]));
PR_WaitSem(sem[0]);
DPRINTF(("SemaThread: thread = 0x%lx posting on sem = 0x%lx\n",
}
--alive;
}
{
alive = 2;
cxq = 0;
0);
} else {
DPRINTF(("SemaContextSwitch: created %s thread = 0x%lx\n",
(scope1 == PR_GLOBAL_THREAD ?
"PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD"),
t1));
}
0);
} else {
DPRINTF(("SemaContextSwitch: created %s thread = 0x%lx\n",
(scope2 == PR_GLOBAL_THREAD ?
"PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD"),
t2));
}
/* Wait for both of the threads to exit */
while (alive) {
}
PR_DestroySem(sem_set1[0]);
}
static void SemaContextSwitchUU(void)
{
}
static void SemaContextSwitchUK(void)
{
}
static void SemaContextSwitchKU(void)
{
}
static void SemaContextSwitchKK(void)
{
}
/************************************************************************/
{
double d;
start = PR_IntervalNow();
(*func)();
d = (double)PR_IntervalToMicroseconds(stop);
}
{
{
if (PL_OPT_BAD == os) continue;
{
case 'd': /* debug mode */
_debug_on = 1;
break;
case 'c': /* loop count */
break;
default:
break;
}
}
#ifdef XP_MAC
SetupMacPrintfLog("perf.log");
#endif
lock = PR_NewLock();
mon = PR_NewMonitor();
mon2 = PR_NewMonitor();
printf("--------------\n");
printf("Adding 7 additional CPUs\n");
printf("--------------\n");
PR_Cleanup();
return 0;
}