hello again
i got an assignment i thought i understand it but the every time i read it i understand it differently. my teacher won't explain the exercise.
here is the exercise
[IMG]http://img42.imageshack.us/img42/8331/37255827.png[/IMG]
he also gave an input output example located here
http://rapidshare.com/files/434579925/sorted.zip
i'v learned using shmat & shmget and using semaphore.
i have a few questions
1)if the size given to me is 8 what should i do? am i suppose to use long long?
2)if the size is given to me is 1 one can i use reguar int?
3)i want to do bubblesort and before the swap to lock the semaphore am i right?
4)i started writing 4 cases how does it look
if ((shmid = shmget(IPC_PRIVATE, st.st_size, 0600 | IPC_CREAT)) < 0) {
perror("shmget error");
exit(1);
}
if (num_of_bit != 8) {
if (argv[4] == "signed") {
if ((share1 = (int*) shmat(shmid, NULL, 0)) == (int*) -1) {
perror("shmat error");
exit(1);
}
kind = 1;
} else {
if ((share2 = (unsigned int*) shmat(shmid, NULL, 0))
== (unsigned int*) -1) {
perror("shmat error");
exit(1);
}
kind = 2;
}
} else {
if (argv[4] == "signed") {
if ((share3 = (long long int*) shmat(shmid, NULL, 0))
== (long long int*) -1) {
perror("shmat error");
exit(1);
}
kind = 3;
} else {
if ((share4 = (long long unsigned int*) shmat(shmid, NULL, 0))
== (long long unsigned int*) -1) {
perror("shmat error");
exit(1);
}
kind = 4;
}
}
}
what am i missing?
am just suppose to read the file into the shared memory and then attach a diffrent pointer every time?
tnx allot