Jump to content

Epimetheus

Member
  • Posts

    1,021
  • Joined

  • Last visited

Everything posted by Epimetheus

  1. I see. Well, i've already seen for myself multi-threading isn't an easy topic, lol. Mainly because my program doesn't work
  2. Is it just bad programming practice or it's just straight up not going to work? Because I think the array gets shared, and the main thread doesn't do anything while the other two threads work. I'm it this way mainly because I haven't studied threads fully yet, just the basics, and my professor doesn't look like he knows what he's doing - that's the main reason why I want to get ahead by myself
  3. Well sorry, i'm used to writing the codes for myself, so I don't comment usually. Second, the two "lookname" functions isn't a problem, i was checking out if the surefire way would've worked. Third- are you sure? how do I modify the original array? I've already tried it a couple of times in different programs and it worked that way; Fourth - idk, doesn't bother me that much. Also, since i've coded it myself and i just copied this part from another program of mine where it worked, i'm sure asking for another name is how it's supposed to work. If you want i can send the file to you so you can compile for yourself
  4. Well, the two threads handle each one half of the array, they should be fine
  5. why do they restart though? When i don't end them they just loop? Even so, i've written t1.join() afterwards, i should've ended it. The threads definitely exit the for loop, but then they just restart
  6. it doesn't stop even when i put in "Fine" directly. It just never seems to reach the while statement
  7. It was just for debugging purposes, i edited the post rn
  8. #include <iostream> #include <string> #include <fstream> #include <stdlib.h> #include <stdio.h> #include <time.h> #include <thread> using namespace std; struct sPokemon{ string nome; string tipo; int speed; int util; }; void lookname1(int n, sPokemon galardex[],string nome){ int start=0; for(int i=start;i<n/2;i++){ cout<<"i e' "<<i<<endl; if(nome==galardex[i].nome){ galardex[i].util++; break; } } } void lookname2(int n, sPokemon galardex[],string nome){ int start=n/2; for(int j=start;j<n;j++){ cout<<"j e' "<<j<<endl; if(nome==galardex[j].nome){ galardex[j].util++; break; } } } void inserisci(sPokemon galardex[],int n,string privileged_access){ int i; string nome,fine; thread t1,t2; if(privileged_access==""){ do{ fflush(stdin); getline(cin,nome); t1= thread(lookname1,n,galardex,nome); t2= thread(lookname2,n,galardex,nome); t1.join(); t2.join(); }while(nome!="Fine"); } else{ nome=privileged_access; t1= thread(lookname1,n,galardex,nome); t2= thread(lookname2,n,galardex,nome); t1.join(); t2.join(); } } int main(int argc, char** argv) { fstream f1; int i,c=0; string misc; sPokemon galardex[1000]; f1.open("elenco.txt"); while(!f1.eof()){ f1>>misc; if(c==0){ galardex[i].nome=misc; c++; } else if(c==1){ galardex[i].tipo=misc; c++; } else if(c==2){ galardex[i].speed= atoi(misc.c_str()); c++; } else if(c==3){ galardex[i].util= atoi(misc.c_str()); c=0; i++; } } int n=i; f1.close(); int selett; do{ cin>>selett; switch(selett){ case 0: inserisci(galardex,i,""); break; } }while(selett!=0); return 0; } So basically, i'm having a problem in the function inserisci, when i enter the privileged access if. It's supposed to let me enter a name, the program looks for the same name in the list, and if it finds it it ups it count by 1. However, when it's done checking the list, it just loops endlessly, when it is supposed to ask me for another name. I've tried removing the threads, but it isn't working regardless. So what may be the problem?
  9. How is that a question? It all depends if the cpu is good enough to run it, obviously an old pentium or i3 isn't going to cut it but everything above is a good match
  10. oh, that was the firmware. Sorry about that. But yeah my little brother got one a year ago and its ssd froze again and again. My poor brother was stuck with that thing for like 4 months, lol. Got him a crucial bx500, never had a problem since. Great ssd for cheap
  11. it's performing half of what the next worst a400 performs like, there's obviously some kind of problem there
  12. did you update your ssd's drivers? Anyways yeah it's probably the ssd that's slowing everything down
  13. What would be your better options?
  14. i see. Honestly though at this point I might just go for a devastator 3, all the ones linked have some sort of caveat, so i'll just stick to what works for me i guess
  15. By going above my budget, how is the logitech g413 in terms of typing and noise?
  16. Something that uses italian and isn't loud then?
  17. There must be something objective too, like keyboard shortcuts comfortable to reach or a good spot to rest my wrists
  18. Yeah i'm looking for a full size keyboard, and I listed what i need in the answer above. The Corsair K55 actually looked like a really compelling choice but in Italy It costs around 70 euros, and idk how importing from the US works
  19. The problem is, i have no place where I can try out keyboards near to me as far as i know. I don"t really care about mechanical switches (even though it'd be nice), but i'd prefer them not to be squishy and to not produce much noise. Also I really need retroillumination, since lots of times I find myself using the keyboard in the dark. That's the main reason why i'm finally putting my CM Devastator 1 to sleep, the backlighting doesn"t work well anymore. I guess its layout feels comfortable, but idk
  20. Hey guys, i'm looking into buying a new keyboard, and i'm gonna use it mostly for programming, so that means a lot of typing and using shortcuts. What are my best options with a budget of 30-40 euros? I live in Italy, so maybe check prices on Amazon.it
  21. yep definitely FX, it's AMD's older and much worse product lineup, from like 6 years ago. Now there's Ryzen, it's more power efficient than Intel (and especially than FX), and is definitely a beast in terms of price/performance
  22. What does "your friend's past experience with Ryzen" mean? Do you have any info on what happened? Also Ryzen launched 2 years ago, he most probably is referring to FX
×