natarius Posted May 5, 2006 Posted May 5, 2006 hi, for licensing reasons i want to limit my application to only run on one cpu! how can this be done? thx & greets natarius Quote
Leaders snarfblam Posted May 5, 2006 Leaders Posted May 5, 2006 I'm sorry. I can't make the connection between licensing and multithreading. Am I missing something? Besides, can a thread even run accross multiple processors? Quote [sIGPIC]e[/sIGPIC]
Wile Posted May 6, 2006 Posted May 6, 2006 One thread can run on 1 cpu, but if you are using multithreading in your app, two threads of the same application can run on two cpu's. Or just on one, that choice is made by the OS. I dont know, but perhaps an OS can even move a thread from one cpu to another if the load on the orignal cpu becomes to high. I think natarius wants to limit the use of multiple processors if ppl buy a cheaper license. I think all of the proprietary professional databases (MS SQL, Oracle, etc.) have this type of licensing where wanting to use additional cpu's to speed up the database means paying more money ;). This should be possible with the win32api SetProcessAffinityMask I think. Here is some reading on SetProcessAffinityMask The corresponding GetProcessAffinityMask And some overall information from microsoft about using these methods. I dont know if the above mechanisme works on logical CPUs or physical CPUs. 1 single core Intel hyperthreaded CPU is 1 physical cpu, but 2 logical cpus. However a true dualcore processor is 2 physical cpus and 2 logical cpus. Quote Nothing is as illusive as 'the last bug'.
Administrators PlausiblyDamp Posted May 6, 2006 Administrators Posted May 6, 2006 Windows is a SMP (symmetric multiprocessing) based system - this means threads can be scheduled on any availabe cpu (physical or virtual) by the OS regardless. Apart from one or two core OS threads which always run on the first cpu other threads can (and will) freely move between cpus based on cpu availability. Although you could (potentially) use theSetProcessAffinityMask I'm not entirely sure how this would work with .Net as the runtime is multithreaded anyway. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Wile Posted May 7, 2006 Posted May 7, 2006 Although you could (potentially) use theSetProcessAffinityMask I'm not entirely sure how this would work with .Net as the runtime is multithreaded anyway. As far as I understand it (ok, didnt try it myself ;) ) multithreading isnt important for the API. The API works on process level and forces the OS to schedule the process on the amount of CPU's indicated. This can be any kind of process. dotNet might be multithreaded, but COM objects that are free-threaded can also have multiple threads running at the same time, so I dont think multithreading makes it impossible. It would just mean that the multiple threads are all running on the same CPU -> for the process it would be a single cpu box. Quote Nothing is as illusive as 'the last bug'.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.