Globals Storage and Thread-safety

Started by Myron Scottover 24 years ago4 messagespatches
Jump to latest
#1Myron Scott
mkscott@sacadia.com

Hi All,

This patch is to start up a globals storage environment
and, in the future, thread-safety. It includes three new files:

env/env.h -- Header for globals storage
env/env.c -- Source for globals storage and creation
env/thread.h -- Header for possible future thread implementation

I created a new subsystem directory but they can go where appropriate.

Implementation is very much like shared memory storage. The globals
environment is a hashtable that stores stuctures for the various
subsystems. Developers would be able to create structures to store
and retrieve items
that would normally be held in global variables. The hashtable is keyed
by an int that identifies the specific global.

I had to change dynahash.c to use MemoryContexts only if HASH_ALLOC and
HASH_CONTEXT are not set in the control flags.

I have included an example implementation for the MemoryContext globals.
It uses #defines to redefine the globals to the stored
structure if compiled with USE_GLOBAL_ENVIRONMENT. This is probably
should be optimized to reduce the number of calls to retrieve storage but
I will worry about that when and if the patch is accepted.

Thanks,

Myron Scott
mkscott@sacadia.com

Attachments:

globals_patch.difftext/plain; charset=US-ASCII; name=globals_patch.diffDownload+453-36
#2Bruce Momjian
bruce@momjian.us
In reply to: Myron Scott (#1)
Re: Globals Storage and Thread-safety

This has been saved for the 7.3 release:

http://candle.pha.pa.us/cgi-bin/pgpatches2

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

mkscott@sacadia.com wrote:

Hi All,

This patch is to start up a globals storage environment
and, in the future, thread-safety. It includes three new files:

env/env.h -- Header for globals storage
env/env.c -- Source for globals storage and creation
env/thread.h -- Header for possible future thread implementation

I created a new subsystem directory but they can go where appropriate.

Implementation is very much like shared memory storage. The globals
environment is a hashtable that stores stuctures for the various
subsystems. Developers would be able to create structures to store
and retrieve items
that would normally be held in global variables. The hashtable is keyed
by an int that identifies the specific global.

I had to change dynahash.c to use MemoryContexts only if HASH_ALLOC and
HASH_CONTEXT are not set in the control flags.

I have included an example implementation for the MemoryContext globals.
It uses #defines to redefine the globals to the stored
structure if compiled with USE_GLOBAL_ENVIRONMENT. This is probably
should be optimized to reduce the number of calls to retrieve storage but
I will worry about that when and if the patch is accepted.

Thanks,

Myron Scott
mkscott@sacadia.com

Content-Description:

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#3Bruce Momjian
bruce@momjian.us
In reply to: Myron Scott (#1)
Re: Globals Storage and Thread-safety

Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

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

mkscott@sacadia.com wrote:

Hi All,

This patch is to start up a globals storage environment
and, in the future, thread-safety. It includes three new files:

env/env.h -- Header for globals storage
env/env.c -- Source for globals storage and creation
env/thread.h -- Header for possible future thread implementation

I created a new subsystem directory but they can go where appropriate.

Implementation is very much like shared memory storage. The globals
environment is a hashtable that stores stuctures for the various
subsystems. Developers would be able to create structures to store
and retrieve items
that would normally be held in global variables. The hashtable is keyed
by an int that identifies the specific global.

I had to change dynahash.c to use MemoryContexts only if HASH_ALLOC and
HASH_CONTEXT are not set in the control flags.

I have included an example implementation for the MemoryContext globals.
It uses #defines to redefine the globals to the stored
structure if compiled with USE_GLOBAL_ENVIRONMENT. This is probably
should be optimized to reduce the number of calls to retrieve storage but
I will worry about that when and if the patch is accepted.

Thanks,

Myron Scott
mkscott@sacadia.com

Content-Description:

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#4Myron Scott
mkscott@sacadia.com
In reply to: Bruce Momjian (#2)
Re: Globals Storage and Thread-safety

I have attached an updated patch for globals storage. Objects created in
memory are not freed properly in the original patch. This patch properly
uses the TopMemoryContext to create the globals hashtable.

Thanks,

Myron
mkscott@sacadia.com

On Fri, 22 Feb 2002, Bruce Momjian wrote:

Show quoted text

This has been saved for the 7.3 release:

http://candle.pha.pa.us/cgi-bin/pgpatches2

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

mkscott@sacadia.com wrote:

Hi All,

This patch is to start up a globals storage environment
and, in the future, thread-safety. It includes three new files:

env/env.h -- Header for globals storage
env/env.c -- Source for globals storage and creation
env/thread.h -- Header for possible future thread implementation

I created a new subsystem directory but they can go where appropriate.

Implementation is very much like shared memory storage. The globals
environment is a hashtable that stores stuctures for the various
subsystems. Developers would be able to create structures to store
and retrieve items
that would normally be held in global variables. The hashtable is keyed
by an int that identifies the specific global.

I had to change dynahash.c to use MemoryContexts only if HASH_ALLOC and
HASH_CONTEXT are not set in the control flags.

I have included an example implementation for the MemoryContext globals.
It uses #defines to redefine the globals to the stored
structure if compiled with USE_GLOBAL_ENVIRONMENT. This is probably
should be optimized to reduce the number of calls to retrieve storage but
I will worry about that when and if the patch is accepted.

Thanks,

Myron Scott
mkscott@sacadia.com

Content-Description:

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
Bruce Momjian                        |  http://candle.pha.pa.us
pgman@candle.pha.pa.us               |  (610) 853-3000
+  If your life is a hard drive,     |  830 Blythe Avenue
+  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Attachments:

globals_patch.difftext/plain; charset=US-ASCII; name=globals_patch.diffDownload+496-45