N-sim
Emulation and simulation of
Wireless Sensor Networks



   Home


   Project Page


   Download


   CVS



   Installation


   Configuration


   Plug-ins




 Hosted by
SourceForge.net Logo

/home/brennan/n-sim/OrbisQuartus/server/xen/virtual_time-xen.cpp

Go to the documentation of this file.
00001 
00014 /*
00015  * Copyright 2007. Los Alamos National Security, LLC. This material
00016  * was produced under U.S. Government contract DE-AC52-06NA25396 for
00017  * Los Alamos National Laboratory (LANL), which is operated by Los
00018  * Alamos National Security, LLC, for the Department of Energy. The
00019  * U.S. Government has rights to use, reproduce, and distribute this
00020  * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY,
00021  * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL
00022  * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to
00023  * produce derivative works, such modified software should be clearly
00024  * marked, so as not to confuse it with the version available from LANL.
00025  *
00026  * Additionally, this program is free software; you can redistribute
00027  * it and/or modify it under the terms of the GNU General Public
00028  * License as published by the Free Software Foundation; version 2 of
00029  * the License. Accordingly, this program is distributed in the hope
00030  * it will be useful, but WITHOUT ANY WARRANTY; without even the
00031  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00032  * PURPOSE. See the GNU General Public License for more details.
00033  */
00034 
00035 
00036 #include <xenctrl.h>
00037 #include <xenguest.h>
00038 #include <orbisquartus.h>
00039 #include <virtual_time.h>
00040 
00041 
00042 extern pthread_mutex_t sim_mutex;   // from ??
00043 OrbisQuartus *oq;
00044 
00045 
00046 VT_timestamp local_virtual_time(void)
00047 {
00048         VT_timestamp tv;
00050         return tv;
00051 }
00052 
00053 
00054 void *virtual_time_client(void *unused)
00055 {
00056         enum VT_msg_color color = RED;
00057 
00059         while (!daemon_shuttingdown()) {
00060                 while (!daemon_quitting()) {
00061                         pthread_mutex_lock(&vt_sync);
00063                         pthread_mutex_lock(&vt_mutex);
00064                         pthread_mutex_unlock(&vt_sync);
00065 
00066                         pthread_mutex_lock(&sim_mutex);
00068                         color = RED;
00069                         pthread_mutex_unlock(&sim_mutex);
00070 
00076 
00077                         pthread_mutex_lock(&sim_mutex);
00079                         color = WHITE;
00081                         pthread_mutex_unlock(&sim_mutex);
00082                         pthread_mutex_unlock(&vt_mutex);
00083                 }
00084                 // reset trees
00085         }
00086         return NULL;
00087 }
00088 
00089 
00090 void virtual_time_init(OrbisQuartus *orbis)
00091 {
00092         int rc;
00093         oq = orbis;
00094 
00095         if ((rc = pthread_create(&oq->vt_thread, NULL, 
00096                                  init_virtual_time, NULL)) != 0) {
00097                 fprintf(stderr, "ERROR-- virtual time thread: %d\n", rc);
00098                 exit(-1);
00099         }
00100 }


© 2007, Los Alamos National Security, LLC.