Changeset 3725 in vbox for trunk/src/VBox/Additions/os2/VBoxService
- Timestamp:
- Jul 19, 2007 7:01:52 PM (17 years ago)
- Location:
- trunk/src/VBox/Additions/os2/VBoxService
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/os2/VBoxService/VBoxService-os2.cpp
r3655 r3725 23 23 * Global Variables * 24 24 *******************************************************************************/ 25 #ifdef __OS2__25 #ifdef RT_OS_OS2 26 26 # define INCL_BASE 27 27 # define INCL_ERRORS 28 28 # include <os2.h> 29 #endif 29 #endif 30 30 #include <errno.h> 31 31 -
trunk/src/VBox/Additions/os2/VBoxService/VBoxServiceInternal.h
r3655 r3725 1 /* $Id$ */ 1 2 /** @file 2 3 * VBoxService - Guest Additions Services. … … 19 20 */ 20 21 21 #ifndef ___VBoxServiceInternal_h ___22 #define ___VBoxServiceInternal_h ___22 #ifndef ___VBoxServiceInternal_h 23 #define ___VBoxServiceInternal_h 23 24 24 25 /** 25 26 * A service descriptor. 26 27 */ 27 typedef struct 28 typedef struct 28 29 { 29 30 /** The short service name. */ … … 41 42 */ 42 43 DECLCALLBACKMEMBER(int, pfnPreInit)(void); 43 44 44 45 /** 45 46 * Tries to parse the given command line option. 46 47 * 47 48 * @returns 0 if we parsed, -1 if it didn't and anything else means exit. 48 * @param ppszShort If not NULL it points to the short option iterator. a short argument. 49 * @param ppszShort If not NULL it points to the short option iterator. a short argument. 49 50 * If NULL examine argv[*pi]. 50 51 * @param argc The argument count. … … 53 54 */ 54 55 DECLCALLBACKMEMBER(int, pfnOption)(const char **ppszShort, int argc, char **argv, int *pi); 55 56 56 57 /** 57 58 * Called before parsing arguments. … … 60 61 DECLCALLBACKMEMBER(int, pfnInit)(void); 61 62 62 /** Called from the worker thread. 63 * 63 /** Called from the worker thread. 64 * 64 65 * @returns VBox status code. 65 66 * @retval VINF_SUCCESS if exitting because *pfTerminate was set. 66 * @param pfTerminate Pointer to a per service termination flag to check 67 * @param pfTerminate Pointer to a per service termination flag to check 67 68 * before and after blocking. 68 69 */ 69 70 DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfTerminate); 70 71 71 72 /** 72 73 * Stop an service. … … 83 84 /** Pointer to a const VBOXSERVICE. */ 84 85 typedef VBOXSERVICE const *PCVBOXSERVICE; 85 86 86 87 87 88 __BEGIN_DECLS 88 89 … … 98 99 #ifdef __OS2__ 99 100 extern int daemon(int, int); 100 #endif 101 #endif 101 102 102 103 extern VBOXSERVICE g_TimeSync; -
trunk/src/VBox/Additions/os2/VBoxService/VBoxServiceTimeSync.cpp
r3655 r3725 23 23 /** @page pg_vboxservice_timesync The Time Sync Service 24 24 * 25 * The time sync service plays along with the Time Manager (TM) in the VMM 26 * to keep the guest time accurate using the host machine as reference. 25 * The time sync service plays along with the Time Manager (TM) in the VMM 26 * to keep the guest time accurate using the host machine as reference. 27 27 * TM will try its best to make sure all timer ticks gets delivered so that 28 28 * there isn't normally any need to adjust the guest time. 29 * 29 * 30 30 * There are three normal (= acceptable) cases: 31 31 * -# When the service starts up. This is because ticks and such might 32 32 * be lost during VM and OS startup. (Need to figure out exactly why!) 33 * -# When the TM is unable to deliver all the ticks and swallows a 33 * -# When the TM is unable to deliver all the ticks and swallows a 34 34 * backlog of ticks. The threshold for this is configurable with 35 35 * a default of 60 seconds. 36 * -# The time is adjusted on the host. This can be caused manually by 36 * -# The time is adjusted on the host. This can be caused manually by 37 37 * the user or by some time sync daemon (NTP, LAN server, etc.). 38 * 39 * There are a number of very odd case where adjusting is needed. Here 38 * 39 * There are a number of very odd case where adjusting is needed. Here 40 40 * are some of them: 41 41 * -# Timer device emulation inaccurancies (like rounding). … … 43 43 * -# The Guest and/or Host OS doesn't perform proper time keeping. This 44 44 * come about as a result of OS and/or hardware issues. 45 * 46 * The TM is our source for the host time and will make adjustments for 47 * current timer delivery lag. The simplistic approach taken by TM is to 45 * 46 * The TM is our source for the host time and will make adjustments for 47 * current timer delivery lag. The simplistic approach taken by TM is to 48 48 * adjust the host time by the current guest timer delivery lag, meaning that 49 49 * if the guest is behind 1 second with PIT/RTC/++ ticks this should be reflected 50 50 * in the guest wall time as well. 51 * 51 * 52 52 * Now, there is any amount of trouble we can cause by changing the time. 53 * Most applications probably uses the wall time when they need to measure 53 * Most applications probably uses the wall time when they need to measure 54 54 * things. A walltime that is being juggled about every so often, even if just 55 55 * a little bit, could occationally upset these measurements by for instance 56 56 * yielding negative results. 57 * 58 * This bottom line here is that the time sync service isn't really supposed 57 * 58 * This bottom line here is that the time sync service isn't really supposed 59 59 * to do anything and will try avoid having to do anything when possible. 60 * 60 * 61 61 * The implementation uses the latency it takes to query host time as the 62 * absolute maximum precision to avoid messing up under timer tick catchup 62 * absolute maximum precision to avoid messing up under timer tick catchup 63 63 * and/or heavy host/guest load. (Rational is that a *lot* of stuff may happen 64 64 * on our way back from ring-3 and TM/VMMDev since we're taking the route 65 65 * thru the inner EM loop with it's force action processing.) 66 * 67 * But this latency has to be measured from our perspective, which means it 68 * could just as easily come out as 0. (OS/2 and Windows guest only updates 66 * 67 * But this latency has to be measured from our perspective, which means it 68 * could just as easily come out as 0. (OS/2 and Windows guest only updates 69 69 * the current time when the timer ticks for instance.) The good thing is 70 * that this isn't really a problem since we won't ever do anything unless 70 * that this isn't really a problem since we won't ever do anything unless 71 71 * the drift is noticable. 72 * 73 * It now boils down to these three (configuration) factors: 72 * 73 * It now boils down to these three (configuration) factors: 74 74 * -# g_TimesyncMinAdjust - The minimum drift we will ever bother with. 75 75 * -# g_TimesyncLatencyFactor - The factor we multiply the latency by to 76 76 * calculate the dynamic minimum adjust factor. 77 * -# g_TimesyncMaxLatency - When to start discarding the data as utterly 77 * -# g_TimesyncMaxLatency - When to start discarding the data as utterly 78 78 * useless and take a rest (someone is too busy to give us good data). 79 79 */ … … 84 84 * Header Files * 85 85 *******************************************************************************/ 86 #include <unistd.h> 86 #include <unistd.h> 87 87 #include <errno.h> 88 88 #include <time.h> … … 105 105 /** 106 106 * @see pg_vboxservice_timesync 107 * 108 * @remark OS/2: There is either a 1 second resolution on the DosSetDateTime 107 * 108 * @remark OS/2: There is either a 1 second resolution on the DosSetDateTime 109 109 * API or a but in the settimeofday implementation. Thus, don't 110 110 * bother unless there is at least a 1 second drift. 111 111 */ 112 #ifdef __OS2__112 #ifdef RT_OS_OS2 113 113 static uint32_t g_TimeSyncMinAdjust = 1000; 114 114 #else 115 115 static uint32_t g_TimeSyncMinAdjust = 100; 116 #endif 116 #endif 117 117 /** @see pg_vboxservice_timesync */ 118 118 static uint32_t g_TimeSyncLatencyFactor = 8; … … 138 138 /* no short options */; 139 139 else if (!strcmp(argv[*pi], "--timesync-interval")) 140 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 140 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 141 141 &g_TimeSyncInterval, 1, UINT32_MAX - 1); 142 142 else if (!strcmp(argv[*pi], "--timesync-min-adjust")) 143 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 143 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 144 144 &g_TimeSyncMinAdjust, 0, 3600000); 145 145 else if (!strcmp(argv[*pi], "--timesync-latency-factor")) 146 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 146 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 147 147 &g_TimeSyncLatencyFactor, 1, 1024); 148 148 else if (!strcmp(argv[*pi], "--timesync-max-latency")) 149 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 149 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 150 150 &g_TimeSyncMaxLatency, 1, 3600000); 151 151 return rc; … … 156 156 static DECLCALLBACK(int) VBoxServiceTimeSyncInit(void) 157 157 { 158 /* 158 /* 159 159 * If not specified, find the right interval default. 160 160 * Then create the event sem to block on. … … 220 220 if (g_cVerbosity >= 3) 221 221 { 222 VBoxServiceVerbose(3, "Host: %s (MinAdjust: %RU32 ms)\n", 222 VBoxServiceVerbose(3, "Host: %s (MinAdjust: %RU32 ms)\n", 223 223 RTTimeToString(RTTimeExplode(&Time, &HostNow), sz, sizeof(sz)), MinAdjust); 224 VBoxServiceVerbose(3, "Guest: - %s => %RDtimespec drift\n", 224 VBoxServiceVerbose(3, "Guest: - %s => %RDtimespec drift\n", 225 225 RTTimeToString(RTTimeExplode(&Time, &GuestNow), sz, sizeof(sz)), 226 226 &Drift); … … 230 230 /* 231 231 * The drift is to big, we have to make adjustments. :-/ 232 * If we've got adjtime around, try that first - most 232 * If we've got adjtime around, try that first - most 233 233 * *NIX systems have it. Fall back on settimeofday. 234 234 */ 235 235 struct timeval tv; 236 #if !defined( __OS2__) /* PORTME */236 #if !defined(RT_OS_OS2) /* PORTME */ 237 237 RTTimeSpecGetTimeval(Drift, &tv); 238 238 if (adjtime(&tv, NULL) == 0) … … 243 243 } 244 244 else 245 #endif 245 #endif 246 246 { 247 247 errno = 0; … … 253 253 { 254 254 if (g_cVerbosity >= 1) 255 VBoxServiceVerbose(1, "settimeofday to %s\n", 255 VBoxServiceVerbose(1, "settimeofday to %s\n", 256 256 RTTimeToString(RTTimeExplode(&Time, &Tmp), sz, sizeof(sz))); 257 257 #ifdef DEBUG 258 258 if (g_cVerbosity >= 3) 259 VBoxServiceVerbose(2, " new time %s\n", 259 VBoxServiceVerbose(2, " new time %s\n", 260 260 RTTimeToString(RTTimeExplode(&Time, RTTimeNow(&Tmp)), sz, sizeof(sz))); 261 261 #endif … … 318 318 * The 'timesync' service description. 319 319 */ 320 VBOXSERVICE g_TimeSync = 320 VBOXSERVICE g_TimeSync = 321 321 { 322 322 /* pszName. */
Note:
See TracChangeset
for help on using the changeset viewer.