[Barrelfish-users] 3-way Handshake IDC

Dominic Hung domchdh at hku.hk
Wed Nov 19 06:54:15 CET 2014


Dear Team Barrelfish,

I am currently having a trouble with doing a 3-way handshake like IDC. What
I would like to achieve is

Core 0 -- Send Syn -> Core 1
Core 0 <- Send Syn/Ack -- Core 1
Core 0 -- Send Ack --> Core 1

I got no luck doing this on my original system, the message can be sent
from core 0 with no error code but core 1 keep looping waiting for event.
Having troubleshooting for quite some time, then I turned to wrote a
smaller scale testing program to verify that 3-way handshake can be done.
And I still got the same result, i.e., core 0 sent ack with no error code
while core 1 spin waiting for event with no arrival and delivery.

My platform is again... I am sorry, Intel SCC. The latest tag I can compile
with Intel SCC is release2012-11-03 and the real tag I am now using is
release2012-06-06. Hope you may help.

The micro program is as attached.

#include "stdio.h"
#include "stdbool.h" // FOR BOOL
#include <errors/errno.h> // FOR ERRVAL_T
#include "arch/x86_32/barrelfish_kpi/eflags_arch.h"
#include "arch/x86_32/barrelfish_kpi/paging_arch.h"
#include "barrelfish_kpi/syscalls.h" // FOR STRUCT SYSRET
#include "barrelfish/capabilities.h"
#include "if/pingpong_defs.h"
#include "barrelfish/domain.h"
#include "barrelfish/spawn_client.h"
#include "barrelfish/waitset.h"
#include "barrelfish/nameservice_client.h"
#include "rck_dev.h"

struct pingpong_binding* binding;
int flag_connect = 0;
int flag_ack = 0;

void syn_handler(struct pingpong_binding *b){
    debug_printf("arrived at syn\n");

    b->tx_vtbl.syn_ack(b, NOP_CONT);

    do{
        printf("wait ack\n");
        event_dispatch(get_default_waitset());
    } while(!flag_ack);
}

void syn_ack_handler(struct pingpong_binding *b){
    debug_printf("arrived at syn_ack\n");
}

void ack_handler(struct pingpong_binding *b){
    debug_printf("arrived at ack\n");

    flag_ack = 1;
}

struct pingpong_rx_vtbl pingpong_rx_vtbl = {
    .syn     = syn_handler,
    .syn_ack = syn_ack_handler,
    .ack     = ack_handler,
};

static void bind_cb(void *st, errval_t err, struct pingpong_binding *b)
{
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "bind failed");
    }

    printf("client bound!\n");

    // copy my message receive handler vtable to the binding
    b->rx_vtbl = pingpong_rx_vtbl;

    binding = b;
}

static void start_client(void)
{
    iref_t iref;
    errval_t err;

    printf("client looking up '%s' in name service...\n",
"pingpong_service");
    err = nameservice_blocking_lookup("pingpong_service", &iref);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "nameservice_blocking_lookup failed");
    }

    printf("client binding to %"PRIuIREF"...\n", iref);
    err = pingpong_bind(iref, bind_cb, NULL, get_default_waitset(),
IDC_BIND_FLAGS_DEFAULT);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "bind failed");
    }

    while(binding == NULL)
        event_dispatch(get_default_waitset());
}

/* ------------------------------ SERVER ------------------------------ */

static void export_cb(void *st, errval_t err, iref_t iref)
{
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "export failed");
    }

    printf("service exported at iref %"PRIuIREF"\n", iref);

    // register this iref with the name service
    err = nameservice_register("pingpong_service", iref);
    printf("service exported at iref %"PRIuIREF"\n", iref);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "nameservice_register failed");
    }
    printf("service exported at iref %"PRIuIREF"\n", iref);
}

static errval_t connect_cb(void *st, struct pingpong_binding *b)
{
    printf("service got a connection!\n");

    // copy my message receive handler vtable to the binding
    b->rx_vtbl = pingpong_rx_vtbl;

    flag_connect = 1;

    // accept the connection (we could return an error to refuse it)
    return SYS_ERR_OK;
}

static void start_server(void)
{
    errval_t err;

    err = pingpong_export(NULL, export_cb, connect_cb,
get_default_waitset(), IDC_EXPORT_FLAGS_DEFAULT);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "export failed");
    }

    do{
        event_dispatch(get_default_waitset());
    } while(!flag_connect);
}

int main(int argc, char* argv[]){
    debug_printf("%d\n", disp_get_core_id());

    if(disp_get_core_id() == 0){
        spawn_program(1, "/scc/sbin/pingpong", argv, NULL,
SPAWN_NEW_DOMAIN, NULL);

        start_server();
    }
    else start_client();

    if(disp_get_core_id() == 1){
          binding->tx_vtbl.syn(binding, NOP_CONT);
          event_dispatch(get_default_waitset());
          binding->tx_vtbl.ack(binding, NOP_CONT);
          printf("sent ack\n");
    }
    else{
        event_dispatch(get_default_waitset());
    }

    return 0;
}

Thanks again!

Cheers,
Dominic Hung

--------------------------------------------------
C H Dominic Hung, B.Eng. (CE) HK
M. Phil. Student, Dept. of CS., Faculty of Engg.

Mobile: +852-9819-9360
Email: domchdh at hku.hk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.inf.ethz.ch/pipermail/barrelfish-users/attachments/20141119/5d59e845/attachment.html 


More information about the Barrelfish-users mailing list