1/** 2 * \file 3 * \brief Simple test that locks/unlocks a couple of times 4 */ 5 6/* 7 * Copyright (c) 2011, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#include <stdio.h> 16#include <string.h> 17#include <stdlib.h> 18#include <assert.h> 19 20#include <barrelfish/barrelfish.h> 21#include <barrelfish/deferred.h> 22 23#include <skb/skb.h> 24#include <octopus/octopus.h> 25 26#define LOCKIT_CALLS 100000 27 28//static struct periodic_event lock_timer; 29static bool locked = false; 30char* lock = NULL; 31 32static void lockit(void* arg) 33{ 34 errval_t err = SYS_ERR_OK; 35 36 if (!locked) { 37 err = oct_lock("lock_test", &lock); 38 DEBUG_ERR(err, "lock"); 39 assert(err_is_ok(err)); 40 locked = true; 41 } else { 42 err = oct_unlock(lock); 43 DEBUG_ERR(err, "unlock"); 44 assert(err_is_ok(err)); 45 locked = false; 46 free(lock); 47 } 48} 49 50int main(int argc, char *argv[]) 51{ 52 oct_init(); 53 54 /* 55 debug_printf("create periodic event...\n"); 56 err = periodic_event_create(&lock_timer, get_default_waitset(), 57 (300 * 1000), 58 MKCLOSURE(lockit, &lock_timer)); 59 assert(err_is_ok(err)); 60 */ 61 62 for (size_t i = 0; i < LOCKIT_CALLS; i++) { 63 lockit(NULL); 64 } 65 printf("done\n"); 66 return EXIT_SUCCESS; 67} 68