emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Concurrency via isolated process/thread


From: Ihor Radchenko
Subject: Re: Concurrency via isolated process/thread
Date: Thu, 06 Jul 2023 12:31:11 +0000

Po Lu <luangruo@yahoo.com> writes:

>> Or am I missing something?
>> Is there a way to measure how much CPU time is spent allocating memory?
>
> The detail of the interlocking can be increased if and when this is
> demonstrated to be problematic.  Allocating individual Lisp objects
> usually takes a short amount of time: even if no two threads can do so
> at the same time, they will all have ample opportunities to run in
> between consings.

That's why I asked if there is a way to measure how much CPU time
allocating takes.

>> Would it be of interest to allow locking objects for read/write using
>> semantics similar to `with-mutex'?
>
> The problem is interlocking access to low level C state within objects
> and not from Lisp code itself, and also avoiding constructs such as:
>
>   CHECK_STRING (XCAR (foo));
>   foo = XSTRING (XCAR (foo));
>
> where the second load from XCAR (foo)->u.s.car might load a different
> pointer from the one whose type was checked.

I am thinking about some kind of extra flag that will mark an object
locked:

   LOCK_OBJECT (foo);
   LOCK_OBJECT (XCAR (foo));
   CHECK_STRING (XCAR (foo));
   foo = XSTRING (XCAR (foo));
   UNLOCK_OBJECT (XCAR (foo));
   UNLOCK_OBJECT (foo);

LOCK_OBJECT will block until the object is available for use.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]