Windows timer resolution tool in form of system service

Discussion in 'Operating Systems' started by mbk1969, Mar 23, 2013.

  1. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    For info on topic just search for NtSetTimerResolution.

    First version (C++ implementation) of system service:
    http://www.mediafire.com/download.php?a3m87ybzvzugdk6

    First version (C# implementation) of system service:
    http://www.mediafire.com/download.php?i36a8qbi5usa3b6

    Second version (C# implementation) of system service (capability of specifying processes for a timer resolution added):
    http://www.mediafire.com/download.php?by934opu8qox9wc

    All packages contain `Readme.txt' and exe-file.
    Packages of C# implementations also contain cs-file - C# source file which can be compiled to exe-file with C# compiler 'csc.exe' (located in .Net framework folders).

    Second version was implemented for gurus who would notice any process demonstrated weird behavior with maximum timer resolution.

    Differences between versions 1 and 2:
    First version of service just sets maximum timer resolution upon its start.
    Second version of service looks for 'SetTimerResolutionService.exe.ini' file with processes list, and with non-empty ini-file presence following logic is implemented:
    - run process start monitoring;
    - set maximum timer resolution upon first instance of any of listed processes start;
    - set default timer resolution upon last instance of any of listed processes stop.
    In absence of ini-file second version does the same logic as first version.
    In presence of empty ini-file second version does nothing at all.



    Universal PowerShell script for set timer resolution service installation:
    http://www.mediafire.com/download.php?xl0c0r12470rff0

    If you have nether executed any PowerShell scripts, then running
    Code:
    Set-ExecutionPolicy unrestricted
    in PowerShell as the fisrt step is mandatory, because PowerShell restricts script execution by default.

    Just place sript into folder with service`s exe-file. Start script either through context menu or in PowerShell.
    Script is capable to install (and re-install) all mentioned above versions of service.
    Script installs service with acount 'LocalSystem'.
    Script`s actions are:
    - Check folder-owner for an exe-file of service.
    - If exe-file is absent then check folder-owner for a cs-file of service (source file) and invoke C# compiler to build exe-file.
    - Check for a previous instance of STR service.
    - If STR service already installed then stop and uninstall it.
    - Install new instance of STR service and run it.
    Script creates log-file.

    Dear gurus, you can tweak source file of service yourself and rebuild exe-file of service with help of this script - just rename old exe-file.

    There is also Cyberdyne`s script-installer
    Cyberdyne also did full package with all vesrions and install script (bat-file):
    PS All that stuff started in http://forums.guru3d.com/showthread.php?t=368604
    Dedicated post on windows timer processing - http://forums.guru3d.com/showthread.php?t=377790

    Update for Win11:
    https://github.com/amitxv/PC-Tuning...on-in-windows-after-the-the-great-rule-change
    Code:
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel]
    "GlobalTimerResolutionRequests"=dword:00000001
    
     
    Last edited: Mar 1, 2023
    PanosXidis, BetA and 386SX like this.
  2. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    <Reserving space for any future updates>
     
  3. Cyberdyne

    Cyberdyne Guest

    Messages:
    3,580
    Likes Received:
    307
    GPU:
    2080 Ti FTW3 Ultra
    I think I may have messed up something.
    What services does this rely on to start? Because now when I start it is says

    "The Set Timer Resolution Service on this local computer started and then stopped. Some services start automatically if they are not in use by other programs"

    I figure I must have turned something off that it needed but I'm not sure where to start...

    Already tried reinstalling it.
     
  4. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    Give me details, more info, ...
    - Which one version do you use?
    - Did service worked and then you performed any actions and it stopped work? Or it suddenly stopped work?
    - What OS do you have?

    There are no dependencies in this service. It only depends on .Net framework (or on C++ framework). (And I didn`t touch service`s source files for a many days).
    If service started mailfunctioning after you executed new installation script, then possible cullprit is account 'LocalService'. Is there log-file 'STR_Install.log'? And what events do you see in Event viewer?

    You can troubleshoot by installing service manually with account LocalSystem:
    sc.exe delete STR
    sc.exe create STR obj= "NT Authority\LocalSystem" binpath= "c:\...\SetTimerResolutionService.exe" displayname= "Set Timer Resolution Service" start= auto
    (or with InstallUtil.exe)

    In PowerShell you can look at events related to service:
    Get-EventLog -Source STR -LogName Application
    Get-EventLog -Source STR -LogName System


    Another thought - second version of service in presence of non-empty ini-file depends on state of WMI subsystem.

    Edit: I was wrong about default account - it is namely "NT Authority\LocalSystem" (not "NT Authority\LocalService").
     
    Last edited: Mar 24, 2013

  5. Cyberdyne

    Cyberdyne Guest

    Messages:
    3,580
    Likes Received:
    307
    GPU:
    2080 Ti FTW3 Ultra
    I was using the second version with no INI file. It was working fine, I messed with some services and clean up some reg crap, and on restart it started acting like that. I think it may be related to Von Dach's tweaks, but I opted for his tweaks that left WMI alone (because I know your service would probably need that untouched). And I use Windows 7 x64.
    Your log files only tell me that the service was correctly installed.

    I'll give the first version a try...

    Edit: The first version using C# did not work, but your C++ version seems to start...
     
    Last edited: Mar 24, 2013
  6. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    That`s strange because both first version implementations do nothing except for NtSetTimerResolution call... Only difference between them is .Net platform.
    Did you look in event viewer? To simplify events searching you can clear event logs ('Application' & 'System') before service start attempt.
    (In PowerShell:
    clear-eventlog -log application, system
    start-service STR
    (get-service STR).WaitForStatus('Running', [System.TimeSpan]::FromSeconds(10))
    get-eventlog application >> some_file.txt
    get-eventlog system >> some_file.txt
    )

    Edit: BTW, I implemented two utilities for Von Dach`s performance package:

    http://forums.guru3d.com/showpost.php?p=4543129&postcount=296
    http://forums.guru3d.com/showpost.php?p=4548245&postcount=299

    Both can be used for a backup purpose.
     
    Last edited: Mar 24, 2013
  7. Prophet

    Prophet Master Guru

    Messages:
    865
    Likes Received:
    34
    GPU:
    Msi 680
    Gj.

    This is 4 more letters.
     
  8. Cyberdyne

    Cyberdyne Guest

    Messages:
    3,580
    Likes Received:
    307
    GPU:
    2080 Ti FTW3 Ultra
    I used his L3 services set up. Which turns off event log/viewer it seems... lol
    Could that cause this problem in the first place?
    Also, is it important to point out that version 1 and 2 of C# run in x64, but the C++ version runs in x86? (identified by the *32 addendum in taskmanager).
     
    Last edited: Mar 24, 2013
  9. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    Well... As service writes to the event log, those writes can cause an exceptions... I will check this moment and be back...

    Edit: I inserted checks and interceptions into lines with event logging in both C# versions. You can redownload them packages from links in first post. And if my corrections do the job, then you can re-pack and re-upload your cumulative package.
     
    Last edited: Mar 24, 2013
  10. Cyberdyne

    Cyberdyne Guest

    Messages:
    3,580
    Likes Received:
    307
    GPU:
    2080 Ti FTW3 Ultra
    Last edited: Mar 24, 2013

  11. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    Thanks to you - that was a perfect suggestion about disabled event logs... Link in OP I replaced.
     
  12. Prophet

    Prophet Master Guru

    Messages:
    865
    Likes Received:
    34
    GPU:
    Msi 680
    Btw, I vote this for sticky.
     
  13. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    Update for PowerShell script 'Install-STRService.ps1' - read OP...
     
  14. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    Some thoughts about timer resolution and CPU power settings
    http://forums.guru3d.com/showpost.php?p=4564488&postcount=517


    Here is PowerShell script for unhiding most interesting (but not all) CPU power settings:
    http://www.mediafire.com/download.php?m3cgvw73c03fn47

    After script execution go to the 'Control Panel > Power Options > Change Plan Settings > Change Advanced Power Settings' and in dialog window you locate 'Processor power settings' tree root node - there live all unhidden settings.
     
    Last edited: Mar 29, 2013
  15. Cyberdyne

    Cyberdyne Guest

    Messages:
    3,580
    Likes Received:
    307
    GPU:
    2080 Ti FTW3 Ultra
    Not sure if should post in response here or the thread on the other section since you post everything in both places anyway lol.
    But I understand, traffic and all.
    Thanks for the convenience.


    Uh. Not sure why. But, rightclicking the file and selecting "Run with Powershell" makes a prompt show up, but then some red text shows up and it closes too fast for me to read it.

    I remember you saying how you need to make your ps1 scripts with work with a newer version of something another because Windows 7 is different by default?
    IDK. I just know it aint working.
     
    Last edited: Mar 29, 2013

  16. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    Just run PowerShell and execute script there. You will see error text... Send it to me:
    $error[0] > c:\somefolder\errors.txt
    - saving error text to file after script execution.

    May be you already deleted 'Attributes' values under those regystry keys (or one key). Do you see mutliple settings in mentiond dialog under CPU settings tree node?
     
    Last edited: Mar 29, 2013
  17. Cyberdyne

    Cyberdyne Guest

    Messages:
    3,580
    Likes Received:
    307
    GPU:
    2080 Ti FTW3 Ultra
    Well, I added the cpu parking options a long time ago.
    Anyway, this is what I get.
    [​IMG]
     
  18. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    Execute inside PowerShell

    Set-ExecutionPolicy RemoteSigned
    or
    Set-ExecutionPolicy Unrestricted

    PowerShell by default restricts script execution. So user must set this policy to allow script execution.
    For a help:
    get-help Set-ExecutionPolicy -online
     
    Last edited: Mar 29, 2013
  19. Cyberdyne

    Cyberdyne Guest

    Messages:
    3,580
    Likes Received:
    307
    GPU:
    2080 Ti FTW3 Ultra
    Ok, that worked wonderfully (setting it to Unrestricted that is). Sorry, never touched powershell before.

    So many options. So many.
     
  20. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,505
    Likes Received:
    13,526
    GPU:
    GF RTX 4070
    I am using PowerShell for 2 years now and I keep finding new things and aspects and tricks. I`m in love with this shell! It was created for IT professionals but thing is it can be used at any level of difficulty.

    Here is entry points into PowerShell world:

    1. get list of commands:
    - all
    get-command > c:\somefolder\all_commands.txt

    - started with 'get' verb
    get-command "get-*"
    or
    get-command -verb "get"

    - having 'process' in noun part of command name
    get-command "*-*Process*"
    or
    get-command -noun "*Process*"

    2. get help on any command:
    get-help get-command -full
    or
    get-help get-command -online

    3. command or path completion with Tab - start typing a command or a file path and then press Tab to let PowerShell to complete it for you (and press Tab until you get needed command)

    4. look for all properties and methods of items returned by a command (PS not always shows all properties and it doesn`t show methods):
    - all properties
    get-process -name notepad | format-list *

    - all public members
    get-process -name notepad | get-member

    - Tab completion of property or method of item
    $notepad = get-process -name notepad
    $notepad. - and press Tab so PowerShell shows you all avaliable properties and methods one per Tab press

    5. if you don`t want to look at screen output you just redirect output:
    - to file
    get-process | out-file c:\somepath\all_processes.txt (recreates file)
    get-process | out-file c:\somepath\all_processes.txt -Append (appends to file)
    get-process | add-content c:\somepath\all_processes.txt (appends to file)
    get-process > c:\somepath\all_processes.txt (recreates file)
    get-process >> c:\somepath\all_processes.txt (appends to file)
    (if path contains spaces then take it into quotes)

    - to a special window with table view
    get-process | out-gridview

    - to allow PS-scripts execution
    Set-ExecutionPolicy RemoteSigned
    or
    Set-ExecutionPolicy Unrestricted
     
    Last edited: Nov 7, 2013

Share This Page