Sign in to follow this  
Followers 0
Lytus

Atomic Code

7 posts in this topic

Is there a way with AutoIT to prevent context switches in windows?? I've looked around a bit and cant find one.

Share this post


Link to post
Share on other sites



The way you do it is the same in AutoIt as it is in any other program on Windows. If you want your thread/process to have higher priority, you have to increase the thread/process priority.

For those not familiar with the terminology, context switching is what occurs when the kernel switches from one thread to another. "Atomic code" would be code that would be guaranteed to run from start to end before a context switch is done.

Share this post


Link to post
Share on other sites

Thank you for the response, Valik.

I was hoping there was a code version of this in AutoIT rather than physically going to the task manager and increasing the process's priority, because I'd like a particular segment of the code to be atomic and not the whole program. If I would have to write my own C or C++ code to do this then it may be easier to just change the priority and adjust my program accordingly.

My apologies if some folks didn't understand what I meant in the question. Valik gave a great response. For anybody interested, you can read about it here: http://en.wikipedia.org/wiki/Context_switch. This is useful if you have an event-driven program, where the environment is changing (like a bot for a game GUI), and the program does the right thing 99% of the time and a seriously wrong thing 1% of the time. This occurs because your program could be finished processing the GUI and starting on your program's response, when a context switch happens and the game changes state. Your program will execute based on the erroneus game state, and the affects can range from not noticable to train wreck.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Oh, my 1% chance is Train Wreck! :whistle:

Edited by Lytus

Share this post


Link to post
Share on other sites

That should work!

My last question:

I am unfamiliar with window's process priority. Will setting it to realtime be guaranteed to prevent it from switching to any other program with normal(default) priority?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0