mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Software

Reply
 
Thread Tools
Old 2012-06-01, 00:12   #45
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

100110000000102 Posts
Default

Quote:
Originally Posted by KingKurly View Post
You win this round...!
LOL... You have to love cross posting...

This just shows that in software, like mathematics and life, there is usually more than one way to do something....
chalsall is online now   Reply With Quote
Old 2012-06-01, 01:57   #46
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

226128 Posts
Default

@KingKurly:
LaurV is offline   Reply With Quote
Old 2012-06-01, 02:05   #47
Xyzzy
 
Xyzzy's Avatar
 
"Mike"
Aug 2002

3×2,741 Posts
Default

12.04 LTS:

Code:
$ gcc -ansi -Wall test.c 
test.c: In function ‘onBattery’:
test.c:40:25: warning: implicit declaration of function ‘strstr’ [-Wimplicit-function-declaration]
test.c:40:29: warning: incompatible implicit declaration of built-in function ‘strstr’ [enabled by default]
test.c:51:17: warning: implicit declaration of function ‘atoi’ [-Wimplicit-function-declaration]
$ ./a.out
AC
We merged in chalsall's code. Unfortunately, we do not have a laptop so we have no way of testing if the battery part works. Sorry!
Xyzzy is offline   Reply With Quote
Old 2012-06-01, 03:09   #48
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

11100001101012 Posts
Default A note on chalsall's code

If the file in /sys/ is opened, then his function is guaranteed to return and not check /proc/. This isn't normally an issue, but as chalsall himself told me, handling the errors is the hard part

(You never know if you might open a corrupted file or something silly )
Dubslow is offline   Reply With Quote
Old 2012-06-01, 03:35   #49
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

2×5×7×139 Posts
Default

Quote:
Originally Posted by Dubslow View Post
(You never know if you might open a corrupted file or something silly )
Sigh... The code is sane.

Since /sys/ is a virtual file system, opening a "corrupted" file in such a situation would mean you've got much bigger issues on your hands than possibly mis-detecting if you're on AC or battery....
chalsall is online now   Reply With Quote
Old 2012-06-01, 03:44   #50
KingKurly
 
KingKurly's Avatar
 
Sep 2010
Annapolis, MD, USA

33×7 Posts
Default

Odd observations from my stepfather's laptop... it was upgraded to Ubuntu 12.04 LTS not too long ago. For /sys/class/power_supply/AC/online it uses ACAD instead of AC. And for /proc/acpi/battery/BAT0/state it has BAT1 instead of BAT0.

A few problems here. First, the old code wouldn't work on his laptop. Second, the new code wouldn't work either. Hrmm... what the heck?

The kernel was 3.2.0-24-generic.

Can anyone else confirm these findings? (Look in /sys/class/power_supply and /proc/acpi/battery)

Edit: I don't think it's a safe assumption that the contents of /proc/acpi/battery/BAT0/state are smaller than 180 bytes. Is the code not making that assumption? (I'm mildly rusty on my C.)

Last fiddled with by KingKurly on 2012-06-01 at 03:55 Reason: Additional problem
KingKurly is offline   Reply With Quote
Old 2012-06-01, 05:32   #51
garo
 
garo's Avatar
 
Aug 2002
Termonfeckin, IE

ACC16 Posts
Default

A feature request. I like the newer version of throttle where you specify the percent of time you want to be running. In Multi core systems where memory may be a bottleneck is it possible to stagger the periods of rest between cores? So if I am running 50 throttle I want one core to be running Prime95 half the time and the other core for the rest. Right now both cores run together and rest together.
garo is offline   Reply With Quote
Old 2012-06-01, 06:40   #52
KingKurly
 
KingKurly's Avatar
 
Sep 2010
Annapolis, MD, USA

101111012 Posts
Default

A friend of mine took a look at the battery detection code and came up with this rendition: https://gist.github.com/60de973a8289...comment-338482

I haven't yet checked how often the battery gets polled... that makes quite a difference in how this should be done.

To sleep, for me.
KingKurly is offline   Reply With Quote
Old 2012-06-01, 07:41   #53
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts
Default

Quote:
Originally Posted by KingKurly View Post
A friend of mine took a look at the battery detection code and came up with this rendition: https://gist.github.com/60de973a8289...comment-338482

I haven't yet checked how often the battery gets polled... that makes quite a difference in how this should be done.

To sleep, for me.
On my laptop, "a few minutes" would be a perfect description of about how long it took to recognize changes. A decent guess would then be that it checks every five minutes.
Dubslow is offline   Reply With Quote
Old 2012-06-01, 12:42   #54
Xyzzy
 
Xyzzy's Avatar
 
"Mike"
Aug 2002

3·2,741 Posts
Default

Quote:
So if I am running 50 throttle I want one core to be running Prime95 half the time and the other core for the rest. Right now both cores run together and rest together.
http://www.mersenneforum.org/showthread.php?t=12286
Xyzzy is offline   Reply With Quote
Old 2012-06-02, 06:39   #55
KingKurly
 
KingKurly's Avatar
 
Sep 2010
Annapolis, MD, USA

18910 Posts
Default

Quote:
Originally Posted by Dubslow View Post
On my laptop, "a few minutes" would be a perfect description of about how long it took to recognize changes. A decent guess would then be that it checks every five minutes.
I decided to look at the code. Looks like every 15 seconds.
Code:
./commonc.h:#define TE_BATTERY_CHECK_FREQ     15    /* Check battery every 15 sec. */
./commonb.c:    add_timed_event (TE_BATTERY_CHECK, TE_BATTERY_CHECK_FREQ);
KingKurly is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Prime95 version 27.3 Prime95 Software 148 2012-03-18 19:24
Prime95 version 26.3 Prime95 Software 76 2010-12-11 00:11
Prime95 version 25.5 Prime95 PrimeNet 369 2008-02-26 05:21
Prime95 version 25.4 Prime95 PrimeNet 143 2007-09-24 21:01
When the next prime95 version ? pacionet Software 74 2006-12-07 20:30

All times are UTC. The time now is 15:27.


Fri Jul 16 15:27:24 UTC 2021 up 49 days, 13:14, 1 user, load averages: 1.30, 1.55, 1.66

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.