Git Product home page Git Product logo

revolving-doors's Introduction

Get Started: Before we Begin

Revolving Doors

Learning the illumos Doors API

illumos Doors are a novel form of inter-process communication. They allow a thread in a client process to call a function in a server process, automatically spawning a handler thread in the server process if needed.

overview

This repository includes a set of annotated code examples of increasing complexity, each of which discusses a different aspect of the doors API. Though unusual, this API is not very big. The goal of this project is to help folks become comfortable with the doors API in two or three attempts.

Prerequisites

You should know a little C, and have an interest in systems programming. More specifically, this tutorial assumes you either understand or can teach yourself about the following:

  • When a process opens a file, it gets back a "file descriptor" which is an int
  • Making a "System Call" is really just asking the OS to do something for you
  • C represents arrays by a pointer to the beginning of some data, and its length
  • printf takes some funky arguments, and you have to look those up sometimes.
illumos

Of course, to play with doors, you will need access to illumos! I recommend installing OpenIndiana on a VM on your workstation. Or, if you are an AWS customer, you might find it easier to launch an OmniOS instance in your AWS account.

Sources

I am writing this because there seems to be so little about doors on the internet. Here is what I have been able to gather, in order of usefulness:

Special Thanks

revolving-doors's People

Contributors

jack-morrison avatar robertdfrench avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

revolving-doors's Issues

Have setup guides create an unprivileged user

In order to emphasize privilege separation, we actually need some of the processes to run as a different user. The setup guides should create one or more unprivileged users for the sake of demonstrating this feature.

Add an exercise about integrating shared memory

Instead of copying payloads back and forth over doors, which incurs a performance cost, show how shared memory segments can be shared between the door server and the door client so that control can be passed back and forth without needing to copy large amounts of data.

Emphasize that door performance derives from scheduling

As u/jking13 puts it:

The other bit that might be worth mentioning is that the advantage of a door vs. say a unix socket is that during a door call, the scheduler directly transfers control to the server thread -- so there is a very minimal scheduler overhead compared to other forms of IPC. There's a bit more to it, but probably a bit much for a tutorial.

It would be good to nail down the language as precisely as possible here. Is this the same as bypassing the scheduler? Do we avoid a context switch? Are we guaranteed that the server thread shares the same cpu timeslice as the client thread? Is it appropriate to make a comparison to cooperative scheduling, or has that got different implications

18_backgrounding_processes/server.c has door routines from next step

Looks like in server.c for step 1.8 (18?) has the server.c from step 2 (20?). This preemptively introduces some door specific code before explaining it. That step effectively introduces 2 new topics, of which only 1 is explained. Just a minor detail, and probably not an issue. Just something i noticed!

This tutorial is fantastic btw ๐Ÿ‘

Improve mobile navigation

Github's table of contents is not rendered by default on mobile. You have to click the "show code" button. This is not necessarily an obvious place to hide the content, from the reader's point of view.

port Makefiles to illumos make

The Makefiles all use GNU conventions, but don't have to. Porting them to illumos' make would allow the more natural make test syntax to work as expected. At the moment, if someone tries to do this (instead of gmake test), they get cryptic errors when illumos fails to parse GNU syntax.

Prefer open over stat+creat

Per u/jking13:

doing the stat(2) + creat(2) still leaves a window for something else to create the file between the two calls (and could potentially be a security issue) open(path, O_RDWR|O_CREAT|O_EXCL, mode) to create the path would be preferred -- it will fail if the path already exists.

What controls the maximum door argument size?

On my SmartOS zone, I seem to be able to send door payloads that are about twice as big as I can on my VM running OpenIndiana. What is the difference?

  • Configuration of the host?
  • Hardcoded kernel parameters?
  • Default ulimits?

I suspect this has something to do with stack size, but I am not quite sure what.

Clarify that door passing is a special case of descriptor passing

From u/jking13:

When you talk about passing a door through a door, it might be good to note that you're just using the feature that allows doors to pass file descriptors, just the descriptor in that case happens to be a door -- it could be a file, a socket, a pipe, etc.

This begs the question of whether there are other general means for passing descriptors to another process, and whether one could pass a door descriptor using those. If so it would be good to have a contrasting example so that I do not paint doors as more special than they really are.

Adjust door message size with door_setparam

From u/jking13:

The door_getparam(3C) and door_setparam(3C) can be used to adjust the parameters (including the max message size). I suspect the limit you might be hitting on SmartOS could be related to the resource sizing of the zone -- since some of the results may end up having to use mmap, I believe that can also be a factor.

Would be interesting to compare the defaults on each system, or maybe even use door_setparam in the tutorial to make them equal, so that the message transfer lessons do not have to talk about message size in the abstract.

Add Check for Understanding on A0_result_parameters

This is where we go over the data structures and conventions used for packing / unpacking arguments to / from door_calls, but there are no "Check for Understanding" questions at the bottom. It's a critical point for anyone wanting to work with the Doors API, so it's worth providing folks a way to convince themselves that they know what's going on. AND! Some of these structures are kindof subtle if you don't spend the majority of your time in C.

Showcase a DNS server with separate door servers for each DNS zone

The idea being that the DNS server can host records for multiple different zones (belonging to different customers), and that each customer could update their records independently.

sequenceDiagram
  participant DNS Client
  participant DNS Server
  participant example.org Server
  participant example.org Admin
  example.org Admin->>example.org Server: door_call(SET a = 1.2.3.4)
  DNS Client->>DNS Server: udp(LOOKUP a.example.org)
  DNS Server->>example.org Server: door_call(GET a)
Loading

Why do we pass a pointer to the door argument?

We call

door_call(door, &args);

but why? Can the server process modify args? I suspect that if the server returns fewer bytes than expected, the client will want to know, but can any other fields be modified?

Set up a sockets demo for contrast

For #12, we need to show that rpc calls have more latency with sockets than with doors. For #11 we need to show that you can pass a descriptor with the sockets library. Thus, we need an alternate implementation of some of these demos using sockets.

Write SmartOS setup guide

At least navigate folks through setting up a SmartOS zone on Joyent and connecting to it, and setting up gcc. That ain't obvious.

Prefer err.h family of functions over perror+exit

Per u/jking13:

Also illumos (note: it is supposed to intentionally be lowercase, don't ask me why), supports the BSD-style err(), errx(), etc functions via the inclusion of err.h. That could simplify all those perror(...); exit(1) bits. Not necessary, but can be nice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.