Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Cherokee: users

global var in cherokee?

 

 

Cherokee users RSS feed   Index | Next | Previous | View Threaded


pablo at eurodev

Jun 26, 2003, 4:59 PM

Post #1 of 7 (347 views)
Permalink
global var in cherokee?

Hi again,

is gbl_buffer a global var?

Pablo


alvaro at alobbs

Jun 26, 2003, 8:24 PM

Post #2 of 7 (339 views)
Permalink
global var in cherokee? [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 26 June 2003 17:52, pablo neira wrote:

> is gbl_buffer a global var?

Yeah.. it's a global memory buffer.
I added it to avoid the usual "char tmp[len]" local declarations.

We should *only* use it with some rules:

1.- Always use functions that manage ranges and the gbl_buffer_size.
Eg: snprintf

2.- Only use it for internal function usage. We shouldn't use it as a
parameter to another functions (cuz this functions can use it inside and
corrupt gbl_buffer)

- --
Greetings, alo.
http://www.alobbs.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE++z1hVRSCNxlNnu0RAo25AJ9BPgpwf/7KyjtF8KNjcvgMqaH7tQCfXx/b
9qI/JZ6SX20Za7md8cQWVJo=
=PYud
-----END PGP SIGNATURE-----


pablo at eurodev

Jun 26, 2003, 10:51 PM

Post #3 of 7 (337 views)
Permalink
global var in cherokee? [In reply to]

Alvaro Lopez Ortega wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>On Thursday 26 June 2003 17:52, pablo neira wrote:
>
>
>
>>is gbl_buffer a global var?
>>
>>
>
> Yeah.. it's a global memory buffer.
> I added it to avoid the usual "char tmp[len]" local declarations.
>
Hi there!

I ask this because of the multithread support and the logging modules.
We have two choices, keep using this global var and add mutex everytime
it's used, and declare the typical char tmp[len] and this way we don't
need to use the mutex (I think it's better if we use as few mutex as
possible). Well, maybe there are more choices... if so let us know.

bye indians!

Pablo

>
> We should *only* use it with some rules:
>
> 1.- Always use functions that manage ranges and the gbl_buffer_size.
> Eg: snprintf
>
> 2.- Only use it for internal function usage. We shouldn't use it as a
>parameter to another functions (cuz this functions can use it inside and
>corrupt gbl_buffer)
>
>- --
>Greetings, alo.
>http://www.alobbs.com
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.2.2 (GNU/Linux)
>
>iD8DBQE++z1hVRSCNxlNnu0RAo25AJ9BPgpwf/7KyjtF8KNjcvgMqaH7tQCfXx/b
>9qI/JZ6SX20Za7md8cQWVJo=
>=PYud
>-----END PGP SIGNATURE-----
>
>
>


alvaro at alobbs

Jun 26, 2003, 11:15 PM

Post #4 of 7 (336 views)
Permalink
global var in cherokee? [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 26 June 2003 23:43, Pablo wrote:

> >>is gbl_buffer a global var?
> >
> > Yeah.. it's a global memory buffer.
> > I added it to avoid the usual "char tmp[len]" local declarations.
>
> I ask this because of the multithread support and the logging modules.
> We have two choices, keep using this global var and add mutex everytime
> it's used, and declare the typical char tmp[len] and this way we don't
> need to use the mutex (I think it's better if we use as few mutex as
> possible). Well, maybe there are more choices... if so let us know.

I bet for a global per thread gbl_buffer instance :-) (efficient, mutex free,
and more or less clean). :-)

What do you think? :)

- --
Greetings, alo.
http://www.alobbs.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE++2WiVRSCNxlNnu0RAlbpAKDOrQcQLvy7fXOD+uNhfg6TdAte0QCg1dvf
83zgp0rpb6dABT4L3MxXJcs=
=uGLu
-----END PGP SIGNATURE-----


ajo at godsmaze

Jun 27, 2003, 12:08 AM

Post #5 of 7 (335 views)
Permalink
global var in cherokee? [In reply to]

Hello Alvaro,

Thursday, June 26, 2003, 11:29:06 PM, you wrote:

ALO> -----BEGIN PGP SIGNED MESSAGE-----
ALO> Hash: SHA1


ALO> What do you think? :)


I think it's better declaring a buffer everywhere needed....

declaring a new buffer inside a procedure... means only... 1
instruction (really 2... 1 for keeping the pointer)

MOV pointer,ESP
ADD ESP,#(buffer_size)

it doesn't mean a big overhead, like calling to the operating system
to allocate some more memory ;)


my opinion: it's better to create individual buffers everywhere
needed, so it's totally controlled... and we won't get any
disgusting surprise ... ;)




--
Best regards,
Miguel mailto:ajo [at] godsmaze


pablo at eurodev

Jun 27, 2003, 9:47 AM

Post #6 of 7 (335 views)
Permalink
global var in cherokee? [In reply to]

Miguel Angel Ajo Pelayo wrote:

>Hello Alvaro,
>
>Thursday, June 26, 2003, 11:29:06 PM, you wrote:
>
>ALO> -----BEGIN PGP SIGNED MESSAGE-----
>ALO> Hash: SHA1
>
>
>ALO> What do you think? :)
>
>
>I think it's better declaring a buffer everywhere needed....
>
>declaring a new buffer inside a procedure... means only... 1
>instruction (really 2... 1 for keeping the pointer)
>
>MOV pointer,ESP
>ADD ESP,#(buffer_size)
>
>it doesn't mean a big overhead, like calling to the operating system
>to allocate some more memory ;)
>
>
> my opinion: it's better to create individual buffers everywhere
> needed, so it's totally controlled... and we won't get any
> disgusting surprise ... ;)
>

Hi guys,

I agree with you Ajo.

Pablo

>
>
>
>
>
>


alvaro at alobbs

Jun 27, 2003, 3:10 PM

Post #7 of 7 (338 views)
Permalink
global var in cherokee? [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 27 June 2003 01:00, Miguel Angel Ajo Pelayo wrote:

> ALO> What do you think? :)
>
> I think it's better declaring a buffer everywhere needed....
>
> declaring a new buffer inside a procedure... means only... 1
> instruction (really 2... 1 for keeping the pointer)
>
> MOV pointer,ESP
> ADD ESP,#(buffer_size)
>
> it doesn't mean a big overhead, like calling to the operating system
> to allocate some more memory ;)

Too much little overheads.. make a big one. :-)

> my opinion: it's better to create individual buffers everywhere
> needed, so it's totally controlled... and we won't get any
> disgusting surprise ... ;)

I think that we should use the global one if we have the choice, otherwise
declare a new local one. Look:

alo [at] tesor:~$ cat p1.c
#include <time.h>

#define gbl_buffer_len 2048
char gbl_buffer[gbl_buffer_len];

void a (void)
{
int i;
char tmp[2048];

for (i=0;i<2048;i++) tmp[i]=tmp[i];
}

void a_gbl (void)
{
int i;

for (i=0;i<gbl_buffer_len;i++)
gbl_buffer[i] = gbl_buffer[i];
}


main()
{
int i;
time_t before;

before = time(NULL);
for (i=0; i<10000000; i++) {
a();
}
printf ("%d\n", time(NULL)-before);


before = time(NULL);
for (i=0; i<10000000; i++) {
a_gbl();
}
printf ("%d\n", time(NULL)-before);
}
alo [at] tesor:~$ gcc p1.c
alo [at] tesor:~$ ./a.out
148
140
alo [at] tesor:~$

We shouldn't start to waste seconds :-)

- --
Greetings, alo.
http://www.alobbs.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+/EUyVRSCNxlNnu0RAqvPAJ0XMuXClzELdvOko1j2/Mi3mzZlQACff7sn
bMA/GAED8MxjHbFyGyVPupE=
=B+c4
-----END PGP SIGNATURE-----

Cherokee users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.