No, there is nothing more that you have to do with it in order to make sure 
that it blocks the next time that it encounters the sem_wait, and runs the 
next time that the sem_t is posted. 

On Thursday 07 August 2003 13:44, Dale Kingston wrote:
> Ok I read through the threads chapter (very nice book btw). Now just
> correct me if I miss understood. I would make a sem_t web_counter; then
> inside the handler for the webserver I add the sem_wait(&web_counter); then
> in game loop unix when I want that thread to run I would
> sem_post(&web_counter); That will allow that thread to run yes?
>
> Now will that run once, and then sit and wait to be posted again? Or would
> I have to have the handler do something to make sure next time it goes to
> loop it waits till it's posted?
>
>
> ----- Original Message -----
> From: "Yun Zhou" <[EMAIL PROTECTED]>
> To: "Dale Kingston" <[EMAIL PROTECTED]>
> Cc: <[email protected]>
> Sent: Thursday, August 07, 2003 11:46 AM
> Subject: Re: Threads question
>
> > The following is not just a tutorial, but rather, an entire book
>
> (completely
>
> > free of charge, avaliable online in HTML):
> >
> > http://www.newriders.com/books/opl/ebooks/0735710430.html
> >
> > Look in chapter 4. It has all the information about threads that you'll
>
> need
>
> > to know :)
> >
> > On Thursday 07 August 2003 12:13, Dale Kingston wrote:
> > > Ok now the tutorials that I could find, they both said that they
>
> wouldn't
>
> > > covert semaphore or metaphore(I think thats what it was called) You
>
> think
>
> > > you could give me a little example of how I would do that?
> > >
> > >
> > > ----- Original Message -----
> > > From: "Yun Zhou" <[EMAIL PROTECTED]>
> > > To: "Dale Kingston" <[EMAIL PROTECTED]>
> > > Cc: <[email protected]>
> > > Sent: Thursday, August 07, 2003 11:15 AM
> > > Subject: Re: Threads question
> > >
> > > > Your plan is workable, but boolean vairables are not commonly used
>
> when
>
> > > > it comes to syncing threads.
> > > >
> > > > This is where the semaphore(include pthread and semaphore.h, link
> > > > with -lpthread) comes into play. When game_loop_unix finishes a loop,
> > > > make
>
> it
>
> > > > update a global data structure with all the data that the webserver
>
> needs
>
> > > to
> > >
> > > > know, then posts a semaphore, unblocking the webserver loop.
> > > >
> > > > On Thursday 07 August 2003 11:42, Dale Kingston wrote:
> > > > > Ok I've been wanting to do this for sometimes but I haven't known
>
> how
>
> > > > > to
> > >
> > > do
> > >
> > > > > it. And then with the resent mention of threads I figured this
> > > > > might
>
> be
>
> > > how
> > >
> > > > > I could do it. I have a web server attached with the mud. You can
>
> see a
>
> > > lot
> > >
> > > > > with it, skills, spells, Pcstores, can login write notes, and see
>
> who's
>
> > > > > online. Well for sometimes I've been wanting this in it's own
>
> process
>
> > > > > or thread. So I read some of the tutorials on how to use threads
> > > > > and I'm
> > >
> > > still
> > >
> > > > > a little confused at how I could use 1 thread to run the web server
> > >
> > > rather
> > >
> > > > > then a thread per request. Here's my idea tell me if I'm total
> > > > > wrong
> > >
> > > with
> > >
> > > > > my thinking.
> > > > >
> > > > >
> > > > >
> > > > > In game_loop_unix I have it called handle_webserver, and so that
>
> runs
>
> > > with
> > >
> > > > > each game loop which I would still like to preserver, so what I was
> > > > > thinking. Is make the thread for the handle_webserver at the end of
>
> our
>
> > > > > init_web server. Then make a two global bools for when it's to run
>
> it's
>
> > > > > update, and then like a web_down bool. Then do like game loop unix
>
> and
>
> > > have
> > >
> > > > > the handle do a while (!web_down) And then inside that have the
>
> other
>
> > > bool
> > >
> > > > > be like if (!update_web){continue;) then in the game loop unix have
>
> it
>
> > > flag
> > >
> > > > > that bool true each time it runs throung. And at the end of the
> > >
> > > handle_web
> > >
> > > > > have it flag it false.
> > > > >
> > > > >
> > > > >
> > > > > Would that work how I'm thinking where it would keep it in it's own
> > >
> > > thread.
> > >
> > > > > And that thread would process all the web server information? Or am
>
> I
>
> > > like
> > >
> > > > > total screwed up on my logic of how to have it work?
> >
> > --
> > ROM mailing list
> > [email protected]
> > http://www.rom.org/cgi-bin/mailman/listinfo/rom


Reply via email to