• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Doubts about multicore

itzitzu

n00b
Joined
Oct 21, 2008
Messages
8
Hi everyboy!

First of all I’d like to apologize for my English because it isn’t very good.
I’m going to start making a program in a multicore and I have some doubts. I wonder if someone can help me.
My intention is putting two different applications in a two core PC and putting each one in a core to make use of the maximum capacity. Is this possible? Appart from that, I’d like to know too if I could somehow say that a concrete interruption affects just one of the cores; in the same way, I’d like that the rest of the interruptions that may appear don’t affect that core even if they were from a higher level. Finally, I’d like to know if the two cores could communicate between them and share information .
As you can see, I’m quite lost with regard to how multicore systems work so if you can’t answer me, could you please show me where I could find out about these things? Books, links,… whatever is good for me to start understanding something.

Thank you in advance
 
itzitzu, this is a programming question I think. You can force a program to run on one core using the set process affinity however as newer processors share the cache between cores I do not think this is as important as it used to be. Interrupts and scheduling is handled by the OS. If you want your program to ignore interrupts you need to install a signal handler. You cannot force programs to ignore interrupts based on the processor it is running on. Programs talk between each other using any of the various IPC mechanisms. If the programs just happen to be running on different cores then you are talking between cores.
 
some point quick, possibly half-assed answers (keep in mind i dont know shit about windows programming, and am only assuming that MS uses similar methods as linux, pthreads/NPTL):

yes you can run 2 applications on seperate cores....possibly even explicitly assign them to specific cores by setting affinity. you can do this by having 2 seperate processes, or a single process with multiple threads.

im not quite sure what you mean by interruptions/concrete interruptions. interrupts are sent to the kernel, by some event in your control or not. this may include hardware interrupts, quantum-expiration/scheduling interrupts, or systems calls, for example. you cant really suppress these from userspace. what you can suppress are signal/notifications of certain events/interrupts to avoid further interrupts. if you're application performs a segment violation or illegal operation (division-by-zero) you will get interrupted, or if some other process sends you a signal, a signal will be put on the process's signal queue corresponding to this event, and you can choose what to do with them, including ignoring them, by masking the signal kind of like what lunix mentioned. so you have limited control over "interrupts"

these 2 processes/threads can communicate by several means. the simplest means (i think) is passing signals back and forth, but that by itself is of limited use since signals generally dont carry payloads/data (but sometimes they can). so what you likely need is shared memory between the processes. you get this for free if you use threads, otherwise you use system calls to map a common peice of memory between the 2 (or more) processes, then stick the data there. the workflow may involve each process polling for data/work, or by each process, or some control process, explicitly notifying the other(s) of work by sending a signal and defining a signal handler to deal with that signal a certain way.

this is my understanding however, be VERY wary :D

but in short...yes, its possible. you should consider putting together a much more detailed explanation of what you want to do and ask in the webmastering/programming forum on how you might approach the problem.
 
wow! that was a lot of information, thank you for your answers. ;) I think I have to review my knowledge about signals and how to handle them. :confused:
I'll do what you'ved told me and post a more detailed explanation in that forum because I've finally realized that it's more a programming problem.
 
The best way to make use of multiple cores/processors in a single program is to use threads.
The advantage is that all threads reside inside the same program space, and can share the same memory.
You do need worry about concurrency though. You have to make sure that when one thread is writing to memory, no other threads will read from that memory. There are various ways of 'locking' access to single thread (mutex, semaphore, critical section, locking on instruction level).
The pitfall here is that this locking adds overhead, and in quite a few cases it's faster to let a single thread handle things than to split it up in multiple threads which mostly sit around waiting for eachother.

So basically we have to know what kind of application you are going to write, and what kind of algoritms you are planning to multithread, before we can give more detailed advice about what kind of approach you could take.
 
Back
Top