mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Software (https://www.mersenneforum.org/forumdisplay.php?f=10)
-   -   is there a way (https://www.mersenneforum.org/showthread.php?t=1070)

Danath 2004-05-08 20:02

[QUOTE]1) I believe there is an API call you can use to send the monitor (or the computer) into a specific power state. After we terminate the screensaver process, we could use that to send the monitor back into 'sleep' mode.[/QUOTE]
In this case there would be a sudden monitor awakening-and-falling asleep, that could annoy user. Take also into account that switching the monitor into stand-by mode and out of it shortens the monitor's life.

[QUOTE]2) The API calls used to get a list of running processes can also get a list of running threads. I have no idea what Prime95's threads would be called, however, which is why I haven't attempted to do this. Increasing the priority class of the Prime95 process should work though (though I realize you say it hasn't), based on this quote from MSDN:

Quote:
The SetPriorityClass function sets the priority class for the specified process. This value together with the priority value of each thread of the process determines each thread's base priority level.[/QUOTE]
The problem is that the main (working) thread has the lowest priority, and increasing the process's (class) priority doesn't increase the thread's priority even to a normal level.

It would be the best to have access to Prime95's internal priority setting option (from the command line), but there is no such a feature implemented (yet, I hope).

We could modify the prime.ini file directly, changing the value of the "Priority" parameter, but this would require restarting the client. You can stop the client running under Win2000/XP as a service using the "net stop" command, and you can stop the client running under Win98/ME by sending the WM_CLOSE message to Prime95's window, if it's not hidden, but how to close it gently if it has the "No Icon" option enabled (so it hasn't a window)? I've played with that before, and did not find a way to make (from the command line) the hidden client save its state and exit. Here is again the lack of command-line features that a program like Prime95 should have... :bounce: Also, the screensaver could kick in many times per day, so the client would be restarted frequently - at the moment when the monitor enters the stand-by mode and at its awakening (maybe it's not a problem for someone, but for me...).

PrimeCruncher 2004-05-08 21:57

Okay, new problem: we can't adjust Prime95's thread or process priorities. Believe me, I've spent the better part of two hours trying to make it work. Which just brings us back to where we were before: set the priority of the screensaver so low that Prime95's priority is higher than it. I have an idea that might work, I'll post again in a little while.

PrimeCruncher 2004-05-08 22:28

Okay, here's the scoop: I can tinker with the priority of the thread and process for the screensaver. I can set it to the lowest process priority possible (IDLE_PRIORITY_CLASS) and the lowest thread priority (THREAD_PRIORITY_IDLE). Unfortunately, at Priority 1, Prime95 uses the same settings, therefore half of the cycles go to the screensaver and half go to Prime95. Thus to get the most cycles possible, Prime95 must use priority 2 or above.

Have just discovered a slight side-effect, will look into it further...

crash893 2004-05-10 17:17

what if you had two instances of prime95

you had one set to pority 1

after x amount of idle time it would end that

and then start one that was set to poroty Y ( whatever you set it too ( 1-10)

then wen it detects it comes out of idle it kills prime95(2) and starts the other lowpority 1


im not sure how you would do it with the prime.ini but you could make two dir's

and modify the working dir to match so that the back up files match

( im just kinda of thinking out loud here ) let me know what you think

tom11784 2004-05-10 18:24

I personally just disable all my screen-savers and such things so I don't have to worry about changing prime95's priority beyond 2 which I did because I also have UD-Agent (cancer research stuff) running and setting prime95 priority to 2 gives it 95~99% cpu when idle

PrimeCruncher 2004-05-10 18:47

[QUOTE=crash893]what if you had two instances of prime95

you had one set to pority 1

after x amount of idle time it would end that

and then start one that was set to poroty Y ( whatever you set it too ( 1-10)

then wen it detects it comes out of idle it kills prime95(2) and starts the other lowpority 1


im not sure how you would do it with the prime.ini but you could make two dir's

and modify the working dir to match so that the back up files match

( im just kinda of thinking out loud here ) let me know what you think[/QUOTE]

A similar solution was discussed above and basically rejected because it would cause excessive start-up, shutdown of the Prime95 program. With two directories you'd also have to move all of the files between them when you did the shutdown/restart, which would cause excessive disk writes. Also, I don't know if doing this will be viewed as 'activity' and kick the computer out of sleep mode.

[QUOTE=tom11784]I personally just disable all my screen-savers and such things so I don't have to worry about changing prime95's priority beyond 2 which I did because I also have UD-Agent (cancer research stuff) running and setting prime95 priority to 2 gives it 95~99% cpu when idle[/QUOTE]

Again, discussed above. In fact, that's the whole point of this thread: the user of a borged PC wants to run a screensaver or he won't run Prime95, period.

Danath 2004-05-15 16:42

1 Attachment(s)
I have finally managed to set Prime95's priority programatically using the method provided by itself - through its menu. I just emulated the walking-through-menus-and-windows procedure, that the user would perform manually, using the mouse or the keyboard (Go to menu > "Advanced" > "Priority..." > Change priority > Click OK). :banana:

I've attached the program that sets the priority. If you run it without parameters, it will set the priority of Prime95 to 4, but if you provide a value in the command line (between 1 and 10, as stated in the Prime95's dialog window, used to set the priority), it will set the priority to that value.

E.g.: SetPrime95Priority 7
(you may rename the file, if you think its name is too long)

The program works as follows: it searches for a window, the title of which contains the string "Prime95", then goes through its menu, activates the "Priority..." option, then changes the text of the corresponding editbox to the value, specified in the command line (or to 4, if there is not one), and "clicks" the OK button. Therefore, it works as if you change the priority manually, using the mouse. That means that Prime95 will continue running, and will just restart the test using the new priority (you can try it manually and see how it goes). While restarting, it will save the current progress (that means writing to disk), but you can't avoid it using this method (hoping that the screensaver won't start/stop too frequently).

Notes:
1. This program will work properly even if Prime95's window is hidden (the NoIcon option is selected).
2. It will work only with GUI version of Prime95 - it won't work with NTPrime (the console version, designed to run as an NT service), because it does not have a menu; for those who use NTPrime the single solution (besides setting the thread's priority, which is harder to implement) is editing directly the prime.ini file and restarting the NTPrime service.
3. If Prime95 is not running, the program will wait one minute for the Prime95's window, then stop.
4. The program does not verify the value, provided as a command line parameter (it just passes the value to Prime95), so if you type a value, different not in the 1-10 range, Prime95 will show an error.

Thanks to the author of Sign Of Misery, the program which I used to make SetPrime95Priority. It's a powerful script editor and compiler, that has a set of commands, used for window managing, keyboard and mouse emulating, patching files, working with registry and many more. It's very simple to combine these commands into scripts, and you don't have to know WinAPI or any programming language to use it. This is not advertising (the program is freeware), I'm just enchanted by the functionality of this useful program (if you are interested, I could write more about it).

PrimeCruncher 2004-05-15 16:46

[QUOTE=Danath]Thanks to the author of Sign Of Misery, the program which I used to make SetPrime95Priority. It's a powerful script editor and compiler, that has a set of commands, used for window managing, keyboard and mouse emulating, patching files, working with registry and many more. It's very simple to combine these commands into scripts, and you don't have to know WinAPI or any programming language to use it. This is not advertising (the program is freeware), I'm just enchanted by the functionality of this useful program (if you are interested, I could write more about it).[/QUOTE]

I would absolutely like to know more about that program!

Now, a more important question: will this 'wake up' the computer if running screensaver or in monitor sleep?

Danath 2004-05-15 19:09

Firstly answering PrimeCruncher's question: since the SetPrime95Priority does not emulate the keypresses, it doesn't make the screensaver stop or monitor wake up, so it's ok. It just executes (internally) the menu commands, changes the editbox's text and sends to "OK" button a "click" message.

Now about Sign Of Misery. It was written by a Russian programmer, who names himself CyberManiac. He has a web-page ([URL]http://inqsoft.tsx.org[/URL]), Russian only. But there is also a "partner" web-page, in English: [URL]http://www.geocities.com/xmemor/2lz/s0m.html[/URL].

Currently there are available version 2.65 (with the update to 2.68) and the pre-release of version 2.7 (with the update to pre-release 2). You may choose the 2.65 (2.68) version as a stable-proved one, or go with the pre-release of 2.7 version, which has many improvements and fixes, but is still a beta. To install the update, simply unzip it into the folder where you installed S0M, replacing the old files.

The program has both Russian and English interfaces, so you can use it if you don't understand Russian, but unfortunately it doesn't have English help yet (Russian only). The help describes the commands S0M has, and is very useful if you don't understand how a certain command works, but that is - no English help available at the moment. However, most of the commands are quite intuitive, so it's not difficult to use them.

Below I attach the SetPrime95Priority script, which you can edit and compile using S0M.

[I][SIZE=1]Edit: Attachment removed due to possible virus.[/SIZE][/I]

lunna 2004-05-16 18:59

Looks like you are nearing a resolution.

One way I was thinking about would be to write a custom screensaver. Its purpose would be to start the user-defined screensaver and when the monitor goes into powersave kill the screensaver. If you want to go this route the source from distributed.net's screensaver multiplexor ([url]http://http.distributed.net/pub/dcti/source/pub-20030303.tar.gz[/url] 1.6MB, file pub-20030303/plat/win/w32ss.cpp) might be valuable. Unfortunately I won't be able to test this out myself anytime soon.

Some random links I found:

HOWTO: Force a Screen Saver to Close Once Started in Windows NT/2000/2003
[url]http://support.microsoft.com/default.aspx?scid=kb;EN-US;140723[/url]

HOWTO: Determine Whether a Screen Saver Is Running on Windows NT
[url]http://support.microsoft.com/default.aspx?scid=kb;EN-US;150785[/url]

HOWTO: Know When Your Screen Saver Starts
[url]http://support.microsoft.com/default.aspx?scid=kb;en-us;238882[/url]

DefScreenSaverProc Function
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/defscreensaverproc.asp[/url]
(if making a screen saver)

PrimeCruncher 2004-05-16 19:09

[QUOTE=lunna]Looks like you are nearing a resolution.

One way I was thinking about would be to write a custom screensaver. Its purpose would be to start the user-defined screensaver and when the monitor goes into powersave kill the screensaver. If you want to go this route the source from distributed.net's screensaver multiplexor ([url]http://http.distributed.net/pub/dcti/source/pub-20030303.tar.gz[/url] 1.6MB, file pub-20030303/plat/win/w32ss.cpp) might be valuable. Unfortunately I won't be able to test this out myself anytime soon.[/QUOTE]

The problem is that there's no way to know when the monitor goes into powersave. Writing a screensaver really wouldn't be worth the effort, especially considering that the target environment for this is a computer that randomly changes the screensaver.

[QUOTE=lunna]Some random links I found:

HOWTO: Force a Screen Saver to Close Once Started in Windows NT/2000/2003
[url]http://support.microsoft.com/default.aspx?scid=kb;EN-US;140723[/url]

HOWTO: Determine Whether a Screen Saver Is Running on Windows NT
[url]http://support.microsoft.com/default.aspx?scid=kb;EN-US;150785[/url]

HOWTO: Know When Your Screen Saver Starts
[url]http://support.microsoft.com/default.aspx?scid=kb;en-us;238882[/url]

DefScreenSaverProc Function
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/defscreensaverproc.asp[/url]
(if making a screen saver)[/QUOTE]

The only thing here that looks good is the second to last link; the others are platform-specific, which I'm trying to avoid. And the last one is for writing a screensaver, which has been proposed several times on this board and shot down every time.


All times are UTC. The time now is 20:46.

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