~ubuntu-branches/ubuntu/saucy/nspr/saucy-updates

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/tests/lock.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-08-10 11:34:26 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090810113426-3uv4diflrkcbdimm
Tags: 4.8-0ubuntu1
* New upstream release: 4.8 (LP: #387812)
* adjust patches to changed upstreanm codebase
  - update debian/patches/99_configure.patch
* update shlibs symbols to include new API elements
  - update debian/libnspr4-0d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
#include <string.h>
88
88
#endif
89
89
 
90
 
#ifdef XP_MAC
91
 
#include "prlog.h"
92
 
#define printf PR_LogPrint
93
 
extern void SetupMacPrintfLog(char *logFile);
94
 
#endif
95
 
 
96
90
static PRIntn failed_already=0;
97
91
static PRFileDesc *std_err = NULL;
98
92
static PRBool verbosity = PR_FALSE;
152
146
    while (loops-- > 0)
153
147
    {
154
148
        PR_Lock(ml);
 
149
        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(ml);
155
150
        PR_Unlock(ml);
156
151
    }
157
152
    PR_DestroyLock(ml);
164
159
    while (contention->loops-- > 0)
165
160
    {
166
161
        PR_Lock(contention->ml);
 
162
        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);
167
163
        contention->contender+= 1;
168
164
        contention->overhead += contention->interval;
169
165
        PR_Sleep(contention->interval);
 
166
        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);
170
167
        PR_Unlock(contention->ml);
171
168
    }
172
169
}  /* LockContender */
193
190
    while (contention->loops-- > 0)
194
191
    {
195
192
        PR_Lock(contention->ml);
 
193
        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);
196
194
        contention->contentious+= 1;
197
195
        contention->overhead += contention->interval;
198
196
        PR_Sleep(contention->interval);
 
197
        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);
199
198
        PR_Unlock(contention->ml);
200
199
    }
201
200
 
234
233
    while (loops-- > 0)
235
234
    {
236
235
        PR_EnterMonitor(ml);
 
236
        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);
237
237
        PR_ExitMonitor(ml);
238
238
    }
239
239
    PR_DestroyMonitor(ml);
245
245
    PRMonitor *ml = (PRMonitor*)arg;
246
246
    if (debug_mode) PR_fprintf(std_err, "Reentrant thread created\n");
247
247
    PR_EnterMonitor(ml);
 
248
    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);
248
249
    if (debug_mode) PR_fprintf(std_err, "Reentrant thread acquired monitor\n");
249
250
    PR_ExitMonitor(ml);
250
251
    if (debug_mode) PR_fprintf(std_err, "Reentrant thread released monitor\n");
258
259
    if (debug_mode) PR_fprintf(std_err, "\nMonitor created for reentrant test\n");
259
260
 
260
261
    PR_EnterMonitor(ml);
 
262
    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);
261
263
    PR_EnterMonitor(ml);
 
264
    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);
262
265
    if (debug_mode) PR_fprintf(std_err, "Monitor acquired twice\n");
263
266
 
264
267
    thread = PR_CreateThread(
266
269
        PR_PRIORITY_LOW, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
267
270
    PR_ASSERT(thread != NULL);
268
271
    PR_Sleep(PR_SecondsToInterval(1));
 
272
    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);
269
273
 
270
274
    PR_ExitMonitor(ml);
 
275
    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);
271
276
    if (debug_mode) PR_fprintf(std_err, "Monitor released first time\n");
272
277
 
273
278
    PR_ExitMonitor(ml);
288
293
    while (contention->loops-- > 0)
289
294
    {
290
295
        PR_EnterMonitor(contention->ml);
 
296
        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);
291
297
        contention->contender+= 1;
292
298
        contention->overhead += contention->interval;
293
299
        PR_Sleep(contention->interval);
 
300
        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);
294
301
        PR_ExitMonitor(contention->ml);
295
302
    }
296
303
}  /* MonitorContender */
317
324
    while (contention->loops-- > 0)
318
325
    {
319
326
        PR_EnterMonitor(contention->ml);
 
327
        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);
320
328
        contention->contentious+= 1;
321
329
        contention->overhead += contention->interval;
322
330
        PR_Sleep(contention->interval);
 
331
        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);
323
332
        PR_ExitMonitor(contention->ml);
324
333
    }
325
334
 
484
493
 /* main test */
485
494
    PR_SetConcurrency(8);
486
495
 
487
 
#ifdef XP_MAC
488
 
        SetupMacPrintfLog("lock.log");
489
 
        debug_mode = 1;
490
 
#endif
491
 
 
492
496
    if (loops == 0) loops = 100;
493
497
    if (debug_mode)
494
498
    {