Progress Report:

hello Vlad,

It took me a lot of time to get familiar with the technical concepts and
terminologies about system system programming. 

The amount of information was  overwhelming at first but now I do
have a sound knowledge about synchronization primitives - spinlocks,
 condition variables, compare-and-swap, test-and-set. And how to use
them. I also spent time going through each line of xthread.d file and
its now committed in my memory.

Questions .. yes! many.
(I found answers to a lot of the questions I faced mostly related to
OS concepts on the internet itself.)

1.  Is test-and-set faster than compare-and-swap?

2.  In [xthread.d, line 104 ]  its mentioned "raw mutex used for thread
suspension/resume". What does a raw mutex refer to here? Is it any
different from a normal mutex? Does by raw mutex you mean .. simply
a mutex (! mutex/condition variable pair) ?

3.  I came across futex. It's a kernel facility the enables fast implementations
of mutex in userspace and is used to implement basic locking. Why don't we
incorporate it in achieving locking ? since Pthread Mutex in the latest Linux
distributions are implemented through Futex logic.

4.  In [xthread.d, line 52 ] I could not understand the 'Create a new thread'
method's  void* (*startroutine)(void*) argument. Please, also provide me
with a definition of startroutine.

5.  In [xthread.d, line 99,152] what does #define THREADPROC_SIGNATURE do?

6.  In [xthread.d, line 156],  its mentioned 'an inefficient implementation of
condition variable for win32.'. Why don't we use windows 'Events' instead of
a condition variable, since I read they are like a mutex/condition pair wrapped 
around a boolean.
plus there's also a to-do marked there-  "TODO : make it better."


On Sat, Apr 26, 2014 at 12:22 PM, shashank <> wrote:
I apologize for the delayed response. I got occupied with college work
and also I was unsure what to write to you since you have given me a lot
of information to study.

Please allow me sometime to go through all this and become familiar with it.
I'll ask question as I face them.

On Thu, Apr 24, 2014 at 12:18 PM, Vladimir Tzankov <> wrote:
Yep, CAS is for Compare-And-Swap. Bear in mind we should support
multiple platforms and compilers. Recent gcc versions have builtin
support for atomic ops but we are not using them since other compilers
do not support them (e.g. msvc).

In xthread.d is platform dependent portability layer - there are
mutex, condition variable and spinlock implementations for posix and
win32. Note that spinlock is special case of compare-and-swap (just
two values 0 or 1).

zthread.d contains lisp land synchronization routines - lisp mutex and
lisp condition variable (called 'exemption').

For hash table implementation you will need both.
1. xthread.d should be extended with CAS (i suggest to extend
testandset macros).
2. you will need this CAS + lisp sync object in order to implement the
hash table.

As an example how to use lisp mutex - see package.d. There are helper
macros in lispbibl.d - WITH_LISP_MUTEX_LOCK which ensure proper
acquire/release handling in case of non-local exits.


On Wed, Apr 23, 2014 at 6:16 PM, shashank <> wrote:
> Affirmative.
> I will CC all my question to clisp-devel list too.
> And I'll try to group together as many questions that I come up
> with into a single email, instead of spanning it over multiple emails.
>> Lock free hash table implementation itself is not very hard but
>> tricky in the details.
> Thanks for clearing this up. I got really worked up since the answer
> to a question here on stackoverflow said "Creating lock free structures
> is extremely hard and only experts in this field can do it.".
>> Also atomic primitives have to be added to xthread.d (cas in particular).
> quick question .. what is cas?
> Also while doing a grep I found zthread.d file.While xthread.d contains
> macros
> for adding thread support, zthread.d contains the multithreading
> implementation (should I look into this too? ).
> So is there a top level file where xthread.c is called ?
> On Wed, Apr 23, 2014 at 12:02 AM, Vladimir Tzankov <>
> wrote:
>> Hey Shashank,
>> I am glad the proposal was accepted - now it's time for the real work :).
>> I'll be quite busy in recent weeks and the preferred way of
>> communication is via emails. I'll try to respond as quickly as I can
>> (but bare in mind there will be some gaps due to travelling). Also CC
>> your questions to clisp-devel.
>> Now it's the time to go over the clisp internals at
>> (Chapter IV). Play around with clisp code
>> base - change some things, run tests, etc. Lock free hash table
>> implementation itself is not very hard but tricky in the details.
>> Making it compatible with CL standard is harder. Also atomic
>> primitives have to be added to xthread.d (cas in particular).
>> So please spend first week or two in getting comfortable with the
>> toolchain, code base and internals. Ask questions.
>> BR
>>   Vlad
>> On Tue, Apr 22, 2014 at 12:14 AM, shashank <>
>> wrote:
>> > Hi
>> >
>> > Hey Vlad and Sam, thank you soo much :D
>> > And also thank you everyone who is a part of CLISP.
>> >
>> > I just found out that I got accepted into Google Summer of Code '14 to
>> > work
>> > with GNU and on CLISP. [0]
>> >
>> > I know I haven't been able to interact more with you guys about the
>> > project
>> > and in general. But thank for spotting the good in me and accepting me
>> > as a
>> > part of clisp team.
>> > This is Exhilarating feeling for me. I am desperately waiting to learn
>> > more
>> > & more from you all under your guidance and I commit that I will be a
>> > really
>> > good student and fun person to work with :)
>> >
>> > I am glad I'll be hanging out more here.
>> > Thanks again
>> >
>> > Best
>> > Shashank
>> >
>> >
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Start Your Social Network Today - Download eXo Platform
>> > Build your Enterprise Intranet with eXo Platform Software
>> > Java Based Open Source Intranet - Social, Extensible, Cloud Ready
>> > Get Started Now And Turn Your Intranet Into A Collaboration Platform
>> >
>> > _______________________________________________
>> > clisp-devel mailing list
>> >
>> >
>> >