1/3/09

Explanation of the code that froze Zune 30


I always have a habit of browsing the hot searches in Google trends, which has the list of most searched item for that day. On Dec 31st morning, I found too many Zune related searches(Zune lockup, Zune no display, Zune issue etc...) in Google. Initially, I wondered if Zune introduced a new product and users found product issues! At that moment, I could not think of any other reasons for the voluminous Zune related searches on a particular day. So, my obvious next stop is the Zune website, where I found the acknowledgment from Microsoft that there is an issue with the existing Zune 30GB version and is being worked out.

Below is the code logic that froze the Zune 30GB version on Dec 31st, 2008. The Zune hardware clock stores the time in the format of 'No of days and seconds' since 1980( Eg: 1835 days, 19999 seconds) So,when the Zune is switched 'ON' and the software starts accessing the hardware clcok, then the  'total number of days etc..' are converted to actual year, month, date, time etc. For instance, 735 days will be year 1982 and Jan 5th. The leap year should be taken into account, while performing this conversion.


Now, to the code bit which calculates the actual year with the number of days:

year = ORIGINYEAR; /* = 1980 */

--step 1
while (days > 365)
{
--step 2
    if (IsLeapYear(year))
    {
--step 3
        if (days > 366)
        {
--step 4
            days -= 366;
            year += 1;
        }
    }
    else
    {
--step 5
        days -= 365;
        year += 1;
    }
}

In the above code, on a non-leap year, the code with 'the number of days' will get into step 1, step2 and will jump to the 'else' clause in step 5 (being a non-leap year). In Step5, the number of days will be decremented by 365 and it will add upto 1 year  upon each substraction.

Whereas, during a leap year, on the last day (ie 366th day), the code will get intostep1, step2, step 3 and it checks for the condition,

--step 3
if (366 > 366)
{

Since there is no 'Else' (or) 'Break' conditon, the flow will do nothing and just stands by!, which caused the Zune to freeze its operation. 

This code will not cause issue, when you restart the Zune on the next day.


Category: $Programming$

0 comments:

Post a Comment

Counter

Favorite?

Add to Technorati Favorites

Blog Archive

 

All the posts reflect my personal views . Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com