Leave a comment

@rethinkdb dog challenge

Rethinkdb recently published a cat challenge. Well, it’s not really a challenging challenge if you can solve it by looking up Vigenère encryption from Wikipedia and following instructions.

I don’t want to debate the pro and cons of the remainder operator in ANSI C and CPython: the two standards adopt one the divisor, the other the dividend’s sign for the result of the remainder operator. While the original K&R C left it to be platform dependent, if I remember correctly. I am not much of  a systems hacker and I am on the wrong side of the Atlantic to submit my candidature, unless they’d consider sponsoring people from Europe — which I doubt.

I find however interesting their additional challenge, the dog command: it’s really a sort of glorified, asynchronous version of tee.

I am preparing for an interview in Berlin tomorrow, so I don’t have the time to write a full blown dog command today, but I did some preliminary research.

Writing non-blocking, Asynchronous I/O is still somewhat platform dependant:

  • On Windows, your best bet is overlapped I/O with FILE_FLAG_OVERLAPPED.
  • On POSIX, you can use aio.h.
  • If you are specifically on Linux, you can go even faster avoiding copying in and out of user space by using tee(2), splice(2) and vmsplice(2).

Given that they wrote a man page for dog, I’d go with the POSIX or Linux solution.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s