V4RB in threads.

Ruslan Zasukhin sunshine at public.kherson.ua
Mon Feb 10 11:10:00 CST 2003


on 2/10/03 1:24 AM, Steve Kellogg at stevekellogg at mezzotechnologies.com
wrote:

> OK, pardon me for asking again and again...  I want to make sure that I
> understand completely:
> 
> 
> Are you saying that you only need to do SEMAPHORES to prevent multiple threads
> from MODIFYING the data in the DB at the same time?

Yes, if you run on X or windows, preemptive threads can stop you any time.

Note, that since cursors have OWN record buffer, you can be safe if each
thread have its own cursor.

You need wrap by e.g. Critical section only call to curs.AddRecord()

> EXAMPLE 1: 
> 
> THREAD 1 creates a cursor and GetsValues and ITERATES the cursor with
> NextRecord. 
> 
> THREAD 2 creates a cursor and GetsValues and ITERATES the cursor with
> NextRecord. 
> 
> 
> NEITHER thread is doing any updates...  Do I need semaphores here?

I think yes, around NextRecord().
Semapohre or simple critical section.

Otherwise, system can stop first cursor in the middle way,
Second cursor MOVE pointer of table to other record, read it
So first cursor now will read fields of that record also.

> EXAMPLE 2: 
> 
> 
> THREAD 1 creates a cursor and GetsValues and ITERATES the cursor with
> NextRecord  (No updates).
> 
> THREAD 2 creates a cursor and GetsValues and ITERATES the cursor with
> NextRecord PLUS UPDATES records.
> 
> Do I need Semaphores around BOTH Threads' DB access here?  Or do I just need
> to protect the DB in THREAD2 whenever it's going to UPDATE the cursor.

RULE:

You need wrap calls that READ/WRITE from disk.


-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://listserv.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list