![]() |
Bug in CPU "daytime"
There seems to be a bug in the CPU "daytime" hours. I wanted daytime to go from 10:30 am to 1:30 am - the hours when I may be working. If the second time is after midnight the program swaps the start and end times.
|
[quote=Jud McCranie;149055]There seems to be a bug in the CPU "daytime" hours. I wanted daytime to go from 10:30 am to 1:30 am - the hours when I may be working. If the second time is after midnight the program swaps the start and end times.[/quote]In source module commonc.c, there's:
[code] if (day_start_time > day_end_time) { temp = day_memory; day_memory = night_memory; night_memory = temp; temp = day_start_time; day_start_time = day_end_time; day_end_time = temp; [/code]... which swaps the day/night memory and day start/end time values in your case. So, you can either: 1. Leave your day start/end times as 10:30 am and 1:30 am, but switch your memory specifications so that the "daytime memory" is actually what you want as your night memory, and vice versa, or 2. Leave your memory figures alone and swap your day start/end times. In either case, prime95 will then use your desired daytime memory allocation from 10:30 am until 1:30 am the following day, and your desired nighttime memory allocation from 1:30 am until 10:30 am the same day. |
[quote=cheesehead;149058]I'm fairly sure you can workaround this by (1) specifying daytime to start at 1:30 am and end at 10:30 am, then (2) put your desired nighttime setting in the daytime field, and your desired daytime setting in the nighttime field.
(I'll look through the source code and come back with an update if necessary.)[/quote] Yes, that makes sense. |
Of course, it would be better for Prime95 to point that out and ask if you want to swap the times. Quite a few people are up after midnight.
|
[QUOTE=Jud McCranie;149055]There seems to be a bug in the CPU "daytime" hours. I wanted daytime to go from 10:30 am to 1:30 am - the hours when I may be working. If the second time is after midnight the program swaps the start and end times.[/QUOTE]
I presume you wanted a 15 hour daytime period. If the code did not do that, then I need to fix it. I'll look at it when I get back from vacation. |
[quote=Prime95;149088]I presume you wanted a 15 hour daytime period. If the code did not do that, then I need to fix it. I'll look at it when I get back from vacation.[/quote]
[quote=cheesehead;149058]In source module commonc.c, there's: [code] if (day_start_time > day_end_time) { temp = day_memory; day_memory = night_memory; night_memory = temp; temp = day_start_time; day_start_time = day_end_time; day_end_time = temp; [/code][/quote]I'd guess it was coded like that assuming people would accidentally put the two values in the wrong spot and so it swaps them, but apparently that means you can't set the night time values to happen past midnight. Did it used to be like this? I don't think so...I recall having night set to 10 pm to 6 am and it seemed to respect the values correctly. |
[QUOTE=Mini-Geek;149107]Did it used to be like this? I don't think so....[/QUOTE]
I'll have to check out the source control system when I return from vacation. |
[quote=Mini-Geek;149107]I'd guess it was coded like that assuming people would accidentally put the two values in the wrong spot and so it swaps them, but apparently that means you can't set the night time values to happen past midnight. Did it used to be like this? I don't think so...I recall having night set to 10 pm to 6 am and it seemed to respect the values correctly.[/quote]
I don't know if it used to be like that or not. Just after I upgraded to version 25 I went through the options and I noticed that the 10:30am (daytime start) and 1:30am (daytime end) were backwards. I thought "why did I put it in that way?" After I changed them I noticed that the program automatically reversed them. |
[quote=cheesehead;149058]In source module commonc.c[/quote]... version 25.7, I should have specified.
In version 24.13, module commonc.c does not have such code, but commonb.c has: [code]/* Return memory available now */ /* Compute the time where we must halt processing to change the */ /* amount of available memory. */ unsigned int avail_mem (void) { time_t t; struct tm *x; unsigned int curtime; /* Set flag indicating we are using a lot of memory */ HIGH_MEMORY_USAGE = TRUE; /* If the same memory is available both day and night, then return */ /* that value and note that we won't have to stop in the future. */ if (DAY_MEMORY == NIGHT_MEMORY) { STOP_TIME = 0; return (DAY_MEMORY); } /* Determine whether it is daytime or nighttime. */ /* Return corresponding available memory. */ /* Set timer for when daytime or nighttime ends. */ time (&t); x = localtime (&t); curtime = x->tm_hour * 60 + x->tm_min; if (DAY_START_TIME < DAY_END_TIME) { if (curtime < DAY_START_TIME) { STOP_TIME = t + (DAY_START_TIME - curtime) * 60; return (NIGHT_MEMORY); } else if (curtime < DAY_END_TIME) { STOP_TIME = t + (DAY_END_TIME - curtime) * 60; return (DAY_MEMORY); } else { STOP_TIME = t + (DAY_START_TIME + 1440 - curtime) * 60; return (NIGHT_MEMORY); } } else { if (curtime < DAY_END_TIME) { STOP_TIME = t + (DAY_END_TIME - curtime) * 60; return (DAY_MEMORY); } else if (curtime < DAY_START_TIME) { STOP_TIME = t + (DAY_START_TIME - curtime) * 60; return (NIGHT_MEMORY); } else { STOP_TIME = t + (DAY_END_TIME + 1440 - curtime) * 60; return (DAY_MEMORY); } } } [/code](Did that have the same practical effect? When I try to figure it out in my head without writing down, there's a spinning sensation ... I'll go for a walk. :-) |
day start = 11:00 am
day end = 10:00 am current time = 10:30 am [code] if (11:00 < 10:00) { //false } else { if (10:30 < 10) { //false } else if (10:30 < 11:00) { //true STOP_TIME = t + (11:00 - 10:30) * 60; return (NIGHT_MEMORY); }[/code]I don't think it's the same. Looks like if you have the day start after the day end and the current time is between the two (in this case, 11 am, 10 am, 10:30 am respectively. Using the example of the OP's times, we could say 10:30 am, 1:30 am, and 6 am respectively, which would be expected to be night), it returns the night memory like it's supposed to. |
A little walk can do wonders for clearing ones mind. :smile:
[quote=Mini-Geek;149175]day start = 11:00 am day end = 10:00 am current time = 10:30 am [code] if (11:00 < 10:00) { //false } else { if (10:30 < 10) { //false } else if (10:30 < 11:00) { //true STOP_TIME = t + (11:00 - 10:30) * 60; return (NIGHT_MEMORY); }[/code]I don't think it's the same.[/quote]Doesn't your example show that at 10:30 am, the night setting is used by v24? That's the same as v25 does. After exchanging day start and end times, it exchanges day and night memory allocations. Thus, at 10:30 am, v25 will consider it to be "day"time, and so will then use the memory allocation that the user originally specified for night, which had been exchanged into the "day" allocation slot. [quote]Looks like if you have the day start after the day end and the current time is between the two (in this case, 11 am, 10 am, 10:30 am respectively.[/quote]Right -- so in v24 it will at that time (10:30 am) use the "night"time memory allocation. So would v25, but accomplished via different means. [quote]Using the example of the OP's times, we could say 10:30 am, 1:30 am, and 6 am respectively, which would be expected to be night), it returns the night memory like it's supposed to.[/quote]Correct, in either v24 or v25. - - - To anyone still confused: Take a little walk; draw a couple of deep breaths; return. |
[quote=cheesehead;149179]Doesn't your example show that at 10:30 am, the night setting is used by v24?[/quote]
Yes. [quote=cheesehead;149179]That's the same as v25 does. After exchanging day start and end times, it exchanges day and night memory allocations. Thus, at 10:30 am, v25 will consider it to be "day"time, and so will then use the memory allocation that the user originally specified for night, which had been exchanged into the "day" allocation slot.[/quote] Hm, yes, but it does it by doing something the user doesn't expect. That might mean that settings don't get set correctly due to what would be called user error but is the product of a bad design (if the user sets the memory first or notices Prime95 reversed the times, it should work, but if the user sets the time, then sets the memory without noticing that it reversed, the user's day/night memory will be reversed, as probably happened to the OP). |
[quote=Mini-Geek;149191]if the user sets the time, then sets the memory without noticing that it reversed, the user's day/night memory will be reversed, as probably happened to the OP).[/quote]I see ... that's not good. If the user's setting were not changed, it wouldn't matter what somersaults were performed internally, but the UI shouldn't mess around.
|
A better approach would be to have an hour by hour setting so you could define any hour as a "daytime" hour. Then it would not matter if you wrapped around midnight or not.
DarJones |
I agree that the present code "works" by flipping both the hours and the memory settings. V24 did not do this (it had 4 different INI file settings). V25 does (it has one setting: Memory=amount1 during time1-time2 else amount2). The bug was introduced in v25 converting the 4 ini settings or 4 values input in the dialog box to the new during/else syntax.
Ugh. I suppose the correct solution is to write out your example settings as: Memory=dayvalue during 10:30-24:00 else dayvalue during 00:00-01:30 else nightvalue Of course, I then need to parse that for the dialog box. |
you turning into an indian george? or is that as ugly to you as it is to me.
DarJones |
Is there anything wrong with this pseudocode? (besides ugly indenting):
[code] [B]if( ([/B]dayStart [B]<[/B] dayEnd [B]and[/B] now [B]>=[/B] dayStart [B]and[/B] now [B]< [/B]dayEnd[B])[/B] [B]or[/B] [B]([/B]dayStart [B]>[/B] dayEnd [B]and[/B] [B]([/B]now [B]>=[/B] dayStart [B]or[/B] now [B]<[/B] dayEnd[B]) ) ) [/B] [B]{[/B] day [B]=[/B] true[B];[/B] [B]} else {[/B] day [B]=[/B] false[B];[/B] [B]}[/B] [/code]That should handle any case whether the day spans across midnight or not, with only one range setting. |
Oh and, by "now" I mean "time elapsed since midnight".
|
I would prefer:
[CODE] DM = 24*60; day = (DM + now - dayEnd) % DM > (DM + dayStart - dayEnd) % DM; [/CODE] all times in minutes past midnight. Jörg p.s. I hope I didn't made a mistake.... |
[quote=Phantomas;150297][code]
DM = 24*60; day = (DM + now - dayEnd) % DM > (DM + dayStart - dayEnd) % DM; [/code]all times in minutes past midnight.[/quote] The DM term is redundant, since you are calculating mod DM: [code] day = (now - dayEnd) % DM > (dayStart - dayEnd) % DM; [/code] |
[quote=jrk;150304]The DM term is redundant, since you are calculating mod DM:
[code] day = (now - dayEnd) % DM > (dayStart - dayEnd) % DM; [/code][/quote] Yes, but as far as I remember there where, at least in the past, different implementations of the modulo operator in case of negativ parameters. mod(-7,10) can result in -7 or +3. So it would be compiler dependent if it works or not. |
| All times are UTC. The time now is 10:29. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.