Page 1 of 1

Differences between BINSEM and SEM?

PostPosted: Tue Sep 03, 2002 9:13 am
by luben
Hello,

After working so long time with SALVO I wish to share some ideas about BINSEM and counting SEMaphores. In my oppinion they are very, very close services and they could be managed from one and the same service with very small changes.

BINSEM are in fact SEMAPHORE that could be signalled only once, I mean if the function that signals semaphore looks like:
.... semaphore_counter++;

the function that signals BINSEM is :
..... semaphore_counter = 1;

All other services should be absolutely equal.

That means - the both services of SEMAPHORE and BINSEMAPHORE could be merged in one service, that has differences only when signaling the event.

Well, sometimes you can use long semaphores (16 bits), that means - if the BINSEM and SEM use absolutely the same service the BINSEM will use more RAM for longer variables.

These are some thoughts about semaphores that could help you to reduce more the code of SALVO.

Regards
Luben


Re: Differences between BINSEM and SEM?

PostPosted: Tue Sep 03, 2002 10:29 am
by luben
Hello,

After I get the reply on my issue "What happens if counting SEMAPHORE overruns " I see that counting semaphores have some "limiter", protecting them not to overrun.
So, one 8 bit semaphore has "limiter" of value "256".

If this "limiter" is set to value 1 - we'll get BINSEM functionality, right?

I mean - SEM and BINSEM have so many similar things, that it's quite possible to be merged somehow into one single service.

Regards
Luben


Re: Differences between BINSEM and SEM?

PostPosted: Wed Sep 04, 2002 8:37 am
by aek
Hi Luben.

This is a very interesting point.

You have Salvo Pro, if I remember correctly.

In salvo.h, change

code:
#if !OSBIG_SEMAPHORES                     
typedef OStypeInt8u OStypeSem;
#define MAX_SEM 255
#else
typedef OStypeInt16u OStypeSem;
#define MAX_SEM 32767
#endif

to
code:
#if !OSBIG_SEMAPHORES                     
typedef OStypeInt8u OStypeSem;
#ifndef MAX_SEM
#define MAX_SEM 255
#endif
#else
typedef OStypeInt16u OStypeSem;
#ifndef MAX_SEM
#define MAX_SEM 32767
#endif
#endif

and then #define MAX_SEM to 1 in your salvocfg.h.

I haven't tried it, but I think it will work ...

Regards,

------------------

[This message has been edited by aek (edited September 04, 2002).]


Re: Differences between BINSEM and SEM?

PostPosted: Wed Sep 04, 2002 8:43 am
by aek
Hi Luben.

What I wrote below won't help because it's a compile-time issue. What you want is a runtime function like this, right?

code:
OSSignalSem(sem, MAX_VALUE)

It requires passing an extra argument, but it probably would reduce codesize. OSSignalBinSem() would become a macro ...

Regards,

------------------


Re: Differences between BINSEM and SEM?

PostPosted: Wed Sep 04, 2002 10:55 am
by luben
Hello,

Maybe the right place to make one semaphore counting or binary is not the OSSignal but OSCreateXYZ. It should add some "limiter" - 1 for BINSEM and 256 to counting semaphores. Then the user should know which is counting and which BIN semaphore.

In short - my idea is to merge all semaphores into one "MEGA" SEMAPHORE. When created with limiter 256 - it's counting semaphore, when created with limiter 1 - BINARY.

Something like:
OSCreateSem(name_of_SEMAPHORE, value, TYPE_OF_SEMAPHORE);

and for the type of semaphore
#define TYPE_BINSEM 1
#define TYPE_COUNT_SEM 256

It's just my vision.

Regards
Luben

[This message has been edited by luben (edited September 04, 2002).]


Re: Differences between BINSEM and SEM?

PostPosted: Wed Jul 08, 2009 11:05 am
by tbims23822
www.drop-shopping.com is a premium website for cheap air jordans shoes and other more really nike air jordan shoes.We have varity of cheap air jordan shoes available for wholesale.Cheap China wholesale shoes including cheap Nike shoes and cheap jordan shoes,nike sneakers,nike sneakers discount,air jordan sneakers,air force sneakers.We supply nike sneakers,jordan sneakers,air jordan sneakers,air force sneakers wholesale.You can buy very cheap jordans shoes including cheap women shoes,cheap nike shoes,cheap running shoes from us.