Share

Embedded Filesystems Library

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Possible problem in Date and Time access

You are viewing a single message from this topic. View all messages.

  1. 2009-02-24 04:00:40 UTC
    Hi all,

    fs_makeTime has a block of code like:
    s = time_getSecond();
    m = time_getMinute();
    h = time_getHour();

    These accesses are not atomic and the underlying RTC may rollover between calls.

    Lets say when minutes are read the time is just about to roll off 2:59:59, seconds and minutes read as "59", but then the RTC rolls over to 3:00:00. Hours now reads as "3".

    so the real time when hours is read is 3:00:00 but the file time will be nearly an hour in the future - 3:59:59.

    A similar problem occurs with fs_makeDate, but in this case it will be rarer and will make the file appear older than it is - but possibly a whole year older! (Lower risk but higher consequence.)

    Wouldn't it be better to have a single fs_getDateTime and then let the underlying system that accesses the clock have the opportunity to lock off updates for the duration of the atomic read?

    Bye for now,
    Ian
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.