[Implemented] Multiple string buffers?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

@Fred

If you haven't received anything in your mailbox please notify me here!
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

whats going on with this thread? some news on it fred? Or is it getting lost?
Tranquil
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

All has been dicussed with Pupil, no I need to implement it.
HarryO
User
User
Posts: 42
Joined: Wed May 07, 2003 4:25 am
Location: Palatine,IL.,USA

Alternative view

Post by HarryO »

Fred,

First, keep up the great work!!!! Love this stuff!!

Second, I know this is late but, what if each thread had it's own copy of the string handler and a local buffer?

When a new thread is created, a copy of the string handleing is created with using it's own string buffer by default (local thread string handling only).

If the string var that is called is declared global then the buffer for the parent process is used.

Would this be easier to implement since you already have the string handler code. Could you re-use the code, just point it to a different buffer?

I know this doesn't solve the problem of handling the global string variables to be thread-safe, but it could be the basis for it.

What does everybody think?

HarryO
SlowByte
New User
New User
Posts: 1
Joined: Tue Jun 03, 2003 10:11 pm

Post by SlowByte »

Hi,

You can make the string buffers thread safe by using TLS (Thread Local Storage) that allocates memory that is unique for every thread (so you don't have to implement your own system).
See the function TlsAlloc, TlsSetValue, TlsGetValue and TlsFree in the Win32 API documentation.

By the way PureBasic looks nice, I'm coding my own language, maybe we'll compete some day (or maybe not, my language going to be a bit more advanced, using type inference and polymorphic functions, if I ever decide to code it) ;)

The PureBasic compiler is not the best I've seen, but it is better than the average, at least it generates native code. You could use some more optimization, look into Single Static Assignment form, Code Flow Graphs and Data Flow Graphs, Three Address Code, and register allocation (Linear Scan Register Allocation, Second-chance binpacking, Graph-coloring and coalescing register allocators).
Get the "Dragon Book" aka "Compilers: Principles, Techniques, and Tools" if you don't have it already.
PureBasic outputted some silly code like "add ebx, 0" and "mov eax, [stuff] mov eax, [morestuff]", use a peephole optimizer :) (of course, an optimizer is not the most important part of the language but it isn't *that* hard to write one if you have spare time))

-Jaen Saul
Post Reply