Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  monref.c   Sprache: C

 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


/*
 * This test program demonstrates that PR_ExitMonitor needs to add a
 * reference to the PRMonitor object before unlocking the internal
 * mutex.
 */


#include "prlog.h"
#include "prmon.h"
#include "prthread.h"

#include <stdio.h>
#include <stdlib.h>

/* Protected by the PRMonitor 'mon' in the main function. */
static PRBool done = PR_FALSE;

static void ThreadFunc(void* arg) {
  PRMonitor* mon = (PRMonitor*)arg;
  PRStatus rv;

  PR_EnterMonitor(mon);
  done = PR_TRUE;
  rv = PR_Notify(mon);
  PR_ASSERT(rv == PR_SUCCESS);
  rv = PR_ExitMonitor(mon);
  PR_ASSERT(rv == PR_SUCCESS);
}

int main() {
  PRMonitor* mon;
  PRThread* thread;
  PRStatus rv;

  mon = PR_NewMonitor();
  if (!mon) {
    fprintf(stderr, "PR_NewMonitor failed\n");
    exit(1);
  }

  thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, mon, PR_PRIORITY_NORMAL,
                           PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
  if (!thread) {
    fprintf(stderr, "PR_CreateThread failed\n");
    exit(1);
  }

  PR_EnterMonitor(mon);
  while (!done) {
    rv = PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);
    PR_ASSERT(rv == PR_SUCCESS);
  }
  rv = PR_ExitMonitor(mon);
  PR_ASSERT(rv == PR_SUCCESS);

  /*
   * Do you agree it should be safe to destroy 'mon' now?
   * See bug 844784 comment 27.
   */

  PR_DestroyMonitor(mon);

  rv = PR_JoinThread(thread);
  PR_ASSERT(rv == PR_SUCCESS);

  printf("PASS\n");
  return 0;
}

Messung V0.5
C=94 H=82 G=88

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge