Jump to content
fallen_angel

Determina nr. de procesoare

Recommended Posts

Posted
Write a computer program that by creating various numbers of processes or threads, will determine the number of processors of the computer.

Are cineva vreo idee? O implementare?

Mul?umesc.

Linux implements max number of threads per process indirectly!!

number of threads = total virtual memory / (stack size*1024*1024)

Thus, the number of threads per process can be increased by increasing total virtual memory or by decreasing stack size. But, decreasing stack size too much can lead to code failure due to stack overflow while max virtual memory is equals to the swap memory.

Check you machine:

Total Virtual Memory: ulimit -v (default is unlimited, thus you need to increase swap memory to increase this)

Total Stack Size: ulimit -s (default is 8Mb)

Command to increase these values:

ulimit -s newvalue

ulimit -v newvalue

*Replace new value with the value you want to put as limit.

References:

http://dustycodes.wordpress.com/2012/02/09/increasing-number-of-threads-per-process/

Sursa

Posted (edited)

N-ai specificat sistemul de operare. Pe windows poti sa faci in felul urmator:

1. Creaza un thread

2. Cu ajutorul functiei:

poti afla pe ce procesor ruleaza thread-ul respectiv.

Teoretic dupa x00(x000?) de thread-uri create, ai "epuizat" toate procesoarele.

PS: Sunt metode mult mai simple pt. a afla numarul procesoarelor, eu am incercat sa ma conformez cerintelor initiale.

Edited by staticwater
Posted (edited)

creezi 1 thread care sa faca ceva intensiv, si vezi cat iti ia sa executi threadul, dupa asta, pornesti mai multe threaduri in acelasi timp si contorizezi pentru fiecare cat iti ia sa executi, verifici timpi, cand ruleaza concurent, verifici timpi de inceput si terminare, numeri numarul de threaduri ce au timpi de pornire si terminare apropiati. Ala e numarul aproximativ de procesoare/threaduri fizice, ce pot rula pe acel procesor. @ceilalti se cere sa se gaseasca o metoda de detectie a numarului de procesoare folosindu-se de threaduri, nu chestii platform dependent.

editat per specificatie :P

Poate migra, atunci cand au unde, ideea era sa creezi mai multe procese simultane care sa ocupe toate corurile procesorului in acelasi timp, cu o actiune ce necesita multa putere de procesare, cum ar fi calcularea fibonnaci pentru un numar mare.

Edited by nedo
Posted

Expresia "restul" se folosea mai de mult in armata. Acum n-o sa-ti explic de ce, dar cuvantul "ceilal?i" ar fi mult mai potrivit in acest caz. :D

Implementarea threadurilor difera de le un sistem de operare la alta + un thread/proces poate "migra" intre procesoare.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...