Can i select my program using processor? [duplicate] - c#

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How Can I Set Processor Affinity in .NET?
I have i7 930x . my computer have cpu 4core.And 8 processor(thread 8)
so.. processor 1 , 2 ,3 ,4 .... 8.
but i want only number 1 processor. i don't want using other phsycal.
c# is possible?
example) my calc program using cpu No1.
my sound program using cpu No2.<br>
my Network A Program using cpu No1.<br>
my Network B Program using cpu No3.<br>

It is possible to set a processor affinity mask for threads/processes to accomplish that. For some high performance programs using thread pools and work queues it can improve performance. In all other cases it is better to let the OS handle the scheduling.

Related

I sent over than 100 requests to web service [duplicate]

This question already has answers here:
Parallel tasks performance in c#
(2 answers)
Closed 1 year ago.
I sent over than 100 requests to web service I am using Parallel.Foreach and it handle it well, but when see the traffic using Wireshark I only see 4 or up to 10 requests per second.
Then I tried the same case on same machine in SOAPUI TOOL in bulk multi threading
Mode then I saw that the 100 requests are sent in same second.
Any advice nothing that I am using
C# 2017
Framework 4.5
OS win 10
CPU cores 4 I7
RAM 16 GB
This is not a parallel.foreach issue - the issue is ServicePointManager which throttles the number of parallel requests to any domain name. The standard is, as you found out, 4 parallel requests.
https://learn.microsoft.com/en-us/dotnet/api/system.net.servicepointmanager?view=net-5.0
Parallel.ForEach will quue all the tasks, but then the requests run into the limitation. Oh, and that manager can be configured ;)

Restart Application If using too much RAM [duplicate]

This question already has answers here:
How to get memory available or used in C#
(6 answers)
Closed 9 years ago.
I'm creating a server (Console App), but after doing some long-term testing I found out it grows eating RAM. For the local test suite, I am not working with much RAM
(8GB-DDR3 #2400MHz)Is there a way (In Program.cs, I assume) to restart the program if it is using over 'x' amount of RAM? Also, one way could be a timed loop/checkup?
You can use GC.GetTotalMemory. It returns an approximate value (long) of how much memory your program has allocated.
You can create a Timer object and make this comparison under the Tick event handler.
For more information, you can look here: http://msdn.microsoft.com/en-us/library/system.gc.gettotalmemory.aspx
I agree with what others have said about fixing your memory leak.
If you want to restart your program, create a second application that monitors the first process. Then, when memory gets too high in your original app, safely shut it down and allow the second application to launch it again.

C# lock vs Java syncronized - Is there any difference in runtime? [duplicate]

This question already has answers here:
Are there any differences between Java's "synchronized" and C#'s "lock"?
(3 answers)
Closed 9 years ago.
I'm wondering if there is any difference in runtime at lock vs syncronized.
I have learnd that syncronized is a slow operation and outdated at Java.
Today I saw the lock at C# and I'm wondering if they are the same and lock is something I "want" to avoid same as in Java or maybe he is much faster and I want to use it...
Thanks!
1 synchronized is not outdated, java.util.concurrent.locks package simply provides extended functions which are not always needed.
2 Locking is done at CPU level and there is no difference between Java and C# in this regard
see http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html
... special instructions, called memory barriers, are required to flush or invalidate the local processor cache in order to see writes made by other processors or make writes by this processor visible to others. These memory barriers are usually performed when lock and unlock actions are taken; they are invisible to programmers in a high level language.

Need help to figure out the unique computer hardware fingerprint [duplicate]

This question already has answers here:
Is WMI a good way to making a hardware fingerprint?
(2 answers)
Closed 9 years ago.
I am creating an licencing system for my windows application and for that i need to create an unique computer identity .
for that i am using
Processor ID and Processor Family
Is this sufficient to create a unique hardware fingerprint or not.
i am little bit confused that Processor ID is unique for all computers or not.
Please provide me an beater idea on that
Thanks
The ProcessorID or CPUID are for identifying the model and feature set of the processor (ARM, x86/x64).
The Pentium III supported a Processor Serial Number (PSN). In addition to only being supported on the Pentium III (and Transmeta's Efficeon and Crusoe processors), the feature had to be enabled in BIOS and raised privacy concerns.
So no, ProcessorID is not unique for all of computers. Additionally, it
is very likely to not be unique across computers in your company
(since many organizations buy multiple computers of the same model).
This question may help you
I know this answer will be better as comment. But I am new and too low to post comments at the moment :(

How to test 500 Trillion combinations in less than 6 hours of execution time [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I have a PHP script now looping through combinations of a set of arrays. I can test 6.1 Billion of the 500 Trillion total combinations in 1 hour with a simple PHP script. Is it possible to write a program in any language running on todays average PC that would be able to test all 500 Trillion combinations of multiple arrays in less than ~6 hours?
Also, I do not have the resources to use distributed or cluster computing for this task. What kind of gains could I expected converting the code to multithreaded java/c#?
Thank you
Let's start simple. Do you use threading? If not - a modern higher end Intel today has 12 hardware threads per processor. This means you get a factor of 12 from threading.
If someone gets a server specific for that he could get 24-32 hardware threads easily for relatively low cost.
If the arrays are semi static and you asume adecent graphics card, you may find having from 800 to 3000 processor cores a huge time saver. Nothing beats this - and even average CPU's have quite some core capabilities in their chips or the graphics cards these days.
500 trillion comparisons in 6 hours
=
83.3 trillion comparisons in 1 hour
=
1.4 trillion comparisons per minute
=
23.1 billion comparisons per second
Assuming you've got an Intel Core i7-2600 cpu (3.4GHz), which is 4 cores + hyperthreading = 8 cores, you'd need a per-core speed of
23.1/6 = 3.9GHz
which is at the extreme end of possibility for basic overclocking.
Once you factor in other overhead, what you want is not possible. Your cpu cannot do NOTHING BUT COMPARISONS.
If you don't have the resources then I'm afraid to say, with the numbers you want, you are buggered.
You'll need to rethink your data structures and the algorithms working on them to have any chance of completing your puzzle within the time limit - using PHP or any other language.
I know nothing about the process you want to run and maybe there is no way to achieve your goals with your current resources, but since you are asking for a language, and it is true that PHP is not the best one to tackle paralelism, I should say that Erlang is famous for that kind of achievements.

Categories