I need to use shared memory and fork to do this:
Multipling random 512x512 matrixes using 4 processes and shared memory. I know how to fork one child but How can I fork 4 proce开发者_运维技巧sses that do 1/4 of work?Thanks
ct = 0;
while (ct < 3 && fork() == 0) {
ct++;
}
ct
will tell you which thread you are. You should probably check for a return of -1
from fork()
, though.
How about this: Read the chapter in your textbook again, ask your classmates for the notes you missed, attack your TA while he or she is sneaking out of his office, then ask your professor during their office hours!
Why don't you just fork three times in a row?
精彩评论