Quantcast

Maximum PC

It is currently Wed Nov 26, 2014 10:56 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: semaphores problem.. (using gcc on Solaris)
PostPosted: Sun Dec 26, 2004 7:41 pm 
Little Foot
Little Foot

Joined: Thu Dec 23, 2004 12:54 pm
Posts: 150
Hey I'm working on an assignment and am having some trouble using semaphores:

I've initialized them such:

struct sembuf declock, inclock, setinit;

sem_key = ftok(....);
semid = semget(semkey, SET_SIZE, PERMS|IPC_CREAT|IPC_EXCL);
set_sembuf_struct(&setinit, 1, value, 0);
semop(semid, &setinit, 1);
set_sembuf_struct(&inclock, 0, 1, 0);
semop(semid, &inclock, 1);

everything appears to go fine until I try using semop:

semop(semid, declock, 1); /* a decrement */

and here's the set_sembuf_struct function:

void set_sembuf_struct(struct sembuf *s, int num, int op, int flg)
{
s->sem_num = (short) num;
s->sem_op = op;
s->sem_flg = flg;
return;
}

heres my gcc output:

1.c: In function `main':
1.c:32: warning: comparison between pointer and integer
1.c:35: error: incompatible type for argument 2 of `semop'

Any help would be SUPERBLY APPRECIATED, THANKS!!!


Top
  Profile  
 
 Post subject:
PostPosted: Sun Dec 26, 2004 10:36 pm 
Team Member Top 100
Team Member Top 100

Joined: Fri Sep 17, 2004 5:35 pm
Posts: 1176
Change that to


semop(semid, &declock, 1); /* a decrement */


I see you did it on all your others, so it looks like it was just a typo :)
Learn to read your compiler's error messages -- they are quite useful ;)

PS- use code tags, please.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 3:07 pm 
Little Foot
Little Foot

Joined: Thu Dec 23, 2004 12:54 pm
Posts: 150
oh, my mistake!

Thanks a lot - it worked like a charm!


Top
  Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 3:59 pm 
Team Member Top 100
Team Member Top 100

Joined: Fri Sep 17, 2004 5:35 pm
Posts: 1176
Any time :)


Top
  Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 2:22 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
In the future, please, please, use the code tags. No one likes reading that unformated code!!! I'm damn near to the point of refusing to help people because it is such a pita to read (and it only takes the poster two seconds to add the tags which benefits everyone).


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.