Few questions about concurrency

rikki cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 27 20:41:41 PDT 2016


On 28/08/2016 3:36 AM, Suliman wrote:
>> Message passing is an alternative to relying on globals + mutex's. In
>> the end its implemented by a global + stack FIFO (mailbox).
>
> Where it's better? Could you give an example?

It is my personal goto when dealing with some form of event loop. Since 
you can set a timeout to receive a message via it.

>> Ring transition e.g. system calls are not all that expensive.
>> Its what the kernel does with that system call that is problematic to
>> performance.
>
> Not fully understand. In first sentence you are saing that is not
> expensive and in second you are saying about "kernel does with that
> system call that is problematic to performance"
 >
> For example vibed is based on Fibers. Does it's mean that:
>
> void handleRequest(HTTPServerRequest req,
>                    HTTPServerResponse res)
> {
>     if (req.path == "/")
>         res.writeBody("Hello, World!", "text/plain");
> }
>
> is fiber-function?

 From memory yes.

Few other things.
A fiber always executes on some form of thread, but a thread doesn't 
have to have any or might have 100's of fibers used with it not that it 
knows either way.

A fiber's job is to allow using more of a threads time slice while some 
other job is blocked (or finished).

I would recommend if you care about this subject to get a hold of 
Windows Internals book by Microsoft. Anything after Vista (5th edition) 
should be good enough. Thrift books[0] has it cheap.

[0] 
https://www.thriftbooks.com/w/windows-internals-pro-developer_mark-russinovich_david-a-solomon/284053/#isbn=0735625301


More information about the Digitalmars-d-learn mailing list