This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Fwd: Re: sntp problems]


Gary Thomas wrote:
Gary Thomas wrote:
Laurie Gellatly wrote:
Couldn't find anyting about the timezone offset.
Looks like it needs to be added in when the time is adjusted back to 1900.


My other problem with the locking up turns out to be the new impolementation
of the I2C clock chip
I'm using and the set_current_time function that calls cyg_drv_dsr_lock.
Trouble is that the I2C clock is interrupt driven and the cyg_drv_dsr_lock
prevents the DSR from running.
I'm using a dallas 1307 variant but I don't see anything in that code that
tries to address this.
Does anyone know why cyg_drv_dsr_lock is used in set_current_time?
Anyone using an interrupt based I2C clock that might have addressed this?

Any piece of code that calls cyg_drv_dsr_lock() and does not provide a way to call cyg_drv_dsr_unlock() is broken. If this is the case, it's no wonder that your system comes to a halt when a NTP update comes in.

The 'set_current_time()' function is not part of eCos, so it's difficult
to analyze this much further.

Sorry, I missed this in .../io/wallclock/current/src/wallclock.cxx


Nonetheless, that's where I'd start looking at the problem. As mentioned
in the note you quoted, this function should be using a mutex for protection,
not DSR locking.

Please try the attached patch (untested) and let me know if it helps.





Thanks ...Laurie:{)


-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org]On Behalf Of Laurie
Gellatly
Sent: Friday, 12 January 2007 9:47 PM
To: eCos discussion
Subject: RE: [ECOS] [Fwd: Re: [ECOS] sntp problems]


Thanks Jonathan, That looks promising. I'll check it out.

...Laurie:{)

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org]On Behalf Of Jonathan
Larmour
Sent: Friday, 12 January 2007 1:44 AM
To: eCos discussion
Subject: [ECOS] [Fwd: Re: [ECOS] sntp problems]


The attached post was mis-directed. - Jifl



-- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss








--
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
Index: io/wallclock/current/src/wallclock.cxx
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/io/wallclock/current/src/wallclock.cxx,v
retrieving revision 1.6
diff -u -5 -p -r1.6 wallclock.cxx
--- io/wallclock/current/src/wallclock.cxx	23 May 2002 23:06:38 -0000	1.6
+++ io/wallclock/current/src/wallclock.cxx	12 Jan 2007 12:46:41 -0000
@@ -85,20 +85,25 @@ static Cyg_WallClock wallclock_instance 
 #ifndef CYGSEM_WALLCLOCK_SET_GET_MODE
 static cyg_uint32 epoch_ticks;
 static cyg_uint32 epoch_time_stamp;
 #endif
 
+static cyg_drv_mutex_t wallclock_lock;
+
 Cyg_WallClock *Cyg_WallClock::wallclock;
 
 //-----------------------------------------------------------------------------
 // Constructor
 
 Cyg_WallClock::Cyg_WallClock()
 {
     // install instance pointer
     wallclock = &wallclock_instance;
 
+    // Initialize lock used for mutually exclusive access to hardware
+    cyg_drv_mutex_init(&wallclock_lock);
+
     // Always allow low-level driver to initialize clock, even though it
     // may not be necessary for set-get mode.
     init_hw_seconds();
 }
 
@@ -109,38 +114,38 @@ Cyg_WallClock::Cyg_WallClock()
 
 cyg_uint32 Cyg_WallClock::get_current_time()
 {
     cyg_uint32 res;
 
-    cyg_drv_dsr_lock();
+    while (!cyg_drv_mutex_lock(&wallclock_lock));
 
 #ifdef CYGSEM_WALLCLOCK_SET_GET_MODE
     res = get_hw_seconds();
 #else
     res = epoch_time_stamp + get_hw_seconds() - epoch_ticks;
 #endif
 
-    cyg_drv_dsr_unlock();
+    cyg_drv_mutex_unlock(&wallclock_lock);
 
     return res;
 }
 
 //-----------------------------------------------------------------------------
 // Sets the clock. Argument is seconds elapsed since 1970-01-01 00:00:00.
 // This may involve reading or writing to the hardware, so it may take
 // anything up to a second to complete.
 void Cyg_WallClock::set_current_time( cyg_uint32 time_stamp )
 {
-    cyg_drv_dsr_lock();
+    while (!cyg_drv_mutex_lock(&wallclock_lock));
 
 #ifdef CYGSEM_WALLCLOCK_SET_GET_MODE
     set_hw_seconds(time_stamp);
 #else
     epoch_time_stamp    = time_stamp;
     epoch_ticks         = get_hw_seconds();
 #endif
 
-    cyg_drv_dsr_unlock();
+    cyg_drv_mutex_unlock(&wallclock_lock);
 }
 
 //-----------------------------------------------------------------------------
 // End of devs/wallclock/wallclock.cxx

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]