[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/umass/apps/StressChkpt Makefile, NONE, 1.1 StressChkptC.nc, NONE, 1.1 StressChkptM.nc, NONE, 1.1 sizes.h, NONE, 1.1

Gaurav gmathur at users.sourceforge.net
Sat Dec 9 13:05:47 PST 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/umass/apps/StressChkpt
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv17795/apps/StressChkpt

Added Files:
	Makefile StressChkptC.nc StressChkptM.nc sizes.h 
Log Message:
Added contrib/umass containing Capsule -- a storage system for sensors

--- NEW FILE: Makefile ---
MSG_SIZE=128
COMPONENT=StressChkptC
PFLAGS=-I%T/lib/Util -g
include ../Makerules


--- NEW FILE: StressChkptC.nc ---
/*
 * Test Compaction
 */
includes common_header;
includes sizes;

configuration StressChkptC {
}

implementation {
    components Main,
      StressChkptM,
      ChunkStorageM,
      FalC,
      ConsoleC,
      LedsC,
      StackM,
      Crc8M,
      StreamM,
      CheckpointM,
      RootDirectoryC;

    Main.StdControl -> StressChkptM;
    Main.StdControl -> FalC;
    Main.StdControl -> ChunkStorageM;
    Main.StdControl -> RootDirectoryC;

    /* Wire the chunk storage system */
    //FlashM -> PageEEPROMC.PageEEPROM[unique("FAL")];
    ChunkStorageM.GenericFlash -> FalC.GenericFlash[unique("Flash")]; 
    ChunkStorageM.Leds -> LedsC;
    ChunkStorageM.Crc8 -> Crc8M;

    /* Wire the data structures */
    StreamM.ChunkStorage -> ChunkStorageM.ChunkStorage[unique("Fal")];
    StreamM.Stack -> StackM.Stack[1];
    StackM.ChunkStorage -> ChunkStorageM.ChunkStorage[unique("Fal")];

    /* Debugging */
    StackM.Leds -> LedsC;
    StreamM.Leds -> LedsC;
    CheckpointM.Leds -> LedsC;
    
    StressChkptM.Console -> ConsoleC;
    StreamM.Console -> ConsoleC;
    StackM.Console -> ConsoleC;
    ChunkStorageM.Console -> ConsoleC;
    RootDirectoryC.Console -> ConsoleC;
    CheckpointM.Console -> ConsoleC;
    FalC.Console -> ConsoleC;
    
    /* Checkpointing */
    CheckpointM.ChunkStorage -> ChunkStorageM.ChunkStorage[unique("Fal")];
    CheckpointM.Stack -> StackM.Stack[unique("Stack")];
    CheckpointM.RootPtrAccess -> StackM.RootPtrAccess[0];
    CheckpointM.RootDirectory -> RootDirectoryC;

    CheckpointM.Serialize -> ChunkStorageM.Serialize;
    CheckpointM.Serialize -> StreamM.Serialize[0];

    /* Compaction */
    ChunkStorageM.Compaction -> StreamM.Compaction[0];

    RootDirectoryC.GenericFlash -> FalC.GenericFlash[unique("Flash")];

    /* Application */
    StressChkptM.ChunkStorage -> ChunkStorageM.ChunkStorage[unique("Fal")];
    StressChkptM.Leds -> LedsC;
    StressChkptM.GenericFlash -> FalC.GenericFlash[unique("Flash")];
    StressChkptM.Stream -> StreamM.Stream[unique("Stream")];
    StressChkptM.Checkpoint -> CheckpointM.Checkpoint;
    StressChkptM.RootDirectory -> RootDirectoryC;
}

--- NEW FILE: StressChkptM.nc ---
/*
 * Measuring the performance of the data structures
 */
includes chunk_header;
includes sizes;

module StressChkptM {
    provides interface StdControl;
    
    uses {
        interface ChunkStorage;
        interface Leds;
        interface Console;
        interface GenericFlash;
        interface Stream;
        interface Checkpoint;
        interface RootDirectory;
    }
}

implementation {
    //flashptr_t fd[COUNT];
    uint8_t i_[LEN], i[LEN];
    uint16_t j, j_;

    bool ecc, busy;
    int count = 0;
    uint16_t pages, current;
    flashptr_t someptr;
    datalen_t len;


    task void format();
 
    task void write_flush()
    {
        if (SUCCESS != call ChunkStorage.flush())
        {
            call Console.string("Flush call failed\n");
            call Leds.redOn();
        }
    }

    event void ChunkStorage.writeDone(result_t res)
    {
        if (res == FAIL)
        {
            call Leds.redOn();
            call Console.string("Write call returned failure\n");
        }
    }

    event void ChunkStorage.flushDone(result_t res)
    {
        if (res == FAIL)
        {
            call Console.string("flush call returned failure\n");
            call Leds.redOn();
        }
    }

    event void ChunkStorage.readDone(result_t res)
    {
        if (res == FAIL)
        {
            call Leds.redOn();
            call Console.string("Read call returned failure\n");
        }
    }


    task void check_checkpt()
    {
        if (SUCCESS != call Checkpoint.checkpoint())
        {
            call Leds.redOn();
            call Console.string("Checkpoint error...\n");
            TOSH_uwait(3000);
        }
    }

    event void Checkpoint.checkpointDone(result_t res)
    {
        if (res == FAIL)
        {
            call Leds.redOn();
            call Console.string("Checkpoint returned failure\n");
        }
    }

    task void check_rollback()
    {
        if (SUCCESS != call Checkpoint.rollback())
        {
            call Leds.redOn();
            call Console.string("Rollback error...\n");
            TOSH_uwait(3000);
        }
    }

    event void Checkpoint.rollbackDone(result_t res)
    {
        if (res == FAIL)
        {
            call Leds.redOn();
            call Console.string("Rollback returned failure\n");
        }
    }
    
    task void check_stream_append()
    {
        if (SUCCESS != call Stream.append(&j, LEN, &someptr))
        {
            call Leds.redOn();
            call Console.string("Error appending...\n");
        }
    }


    event void Stream.appendDone(result_t res)
    {
        if (res == FAIL)
        {
            call Leds.redOn();
            call Console.string("Append call returned failure\n");
        }
        else 
        {
            call Console.string("Append success : ");
            call Console.decimal(j);
            call Console.string(" page:");
            call Console.decimal(someptr.page);
            call Console.string(" off:");
            call Console.decimal(someptr.offset);
            call Console.string("\n");
            TOSH_uwait(3000);
            
            j++;
        }
    }

    task void check_stream_next()
    {
        if (SUCCESS != call Stream.next(&j_, &len))
        {
            call Leds.redOn();
            call Console.string("Error getting next stream element...\n");
        }
    }

    event void Stream.nextDone(result_t res)
    {
        if (res == FAIL)
        {
            call Leds.redOn();
            call Console.string("Next call returned failure\n");
        }
        else 
        {
            call Console.string("Next success : ");
            call Console.decimal(j_);
            call Console.string("\n");
            TOSH_uwait(3000);
        }
    }



    command result_t StdControl.init() 
    {
        busy = 0;
        current = pages = 0;
	    memset(i, 0xAB, LEN);
    	memset(i_, 0x0, LEN);
        count = 0;   

        call Console.init();

        call Leds.init();
        
        return SUCCESS;
    }

    command result_t StdControl.start() 
    {    
#ifdef PLATFORM_TELOSB
        pages = 4096;
#else
        pages = 2048;
#endif

        //call RootDirectory.init();

        post format();

        return SUCCESS;
    }
    
    command result_t StdControl.stop() 
    {
        return SUCCESS;
    }

    event void Console.input(char *s)
    {
        if (s[0] == 'f')
        {
            call Console.string("write flush test...\n");
            post write_flush();
        }

        if ((s[0] == 'f') && (s[1] == 'f'))
        {
            call Console.string("formatting flash...\n");
            post format();
        }

        if ((s[0] == 'd') && (s[1] == 'i'))
            call Stream.init(FALSE);

        if ((s[0] == 'd') && (s[1] == 's'))
            call Stream.start_traversal(NULL);

        if ((s[0] == 'd') && (s[1] == 'a'))
        {
            post check_stream_append();
        }
 
        if ((s[0] == 'd') && (s[1] == 'n'))
        {
            post check_stream_next();
        }

        if ((s[0] == 'c') && (s[1] == 'i'))
            call Checkpoint.init(0);

        if ((s[0] == 'c') && (s[1] == 'c'))
        {
            post check_checkpt();
        }
 
        if ((s[0] == 'c') && (s[1] == 'r'))
        {
            post check_rollback();
        }

        call Console.string("ok...\n");
    }

    task void format()
    {
        if (SUCCESS != call GenericFlash.erase(current))
        {
            call Console.string("ERROR ! erase call failed\n");
            call Leds.redOn();
        }

        current += 1;
    }

    event result_t GenericFlash.eraseDone(result_t r)
    {
        if (SUCCESS != r)
        {
            call Leds.redOn();
            call Console.string("ERROR ! erase call failure - pg: ");
            call Console.decimal(current);
            call Console.string("\n");
            return (FAIL);
        }
        else
        {
            if (current < pages)
            {
                post format();
                //call Console.string("Formatting\n");
            }
            else
            {
                call Console.string("Flash formatted... Ready\n");

                current = 0;
                //call Timer.start(TIMER_REPEAT, 5000);
           }
        }

        return (SUCCESS);
    }
    
    event result_t GenericFlash.initDone(result_t r)
    {
        call Console.string("Init done\n");
        return (SUCCESS);
    }

    event result_t GenericFlash.writeDone(result_t r)
    {
        return (SUCCESS);
    }

    event result_t GenericFlash.readDone(result_t r)
    {
        return (SUCCESS);
    }

    event result_t GenericFlash.falReadDone(result_t r)
    {
        return (SUCCESS);
    }

    event void RootDirectory.initDone(result_t result)
    {
        call Console.string("Root dir init done\n");
    }

    event void RootDirectory.setRootDone(result_t result)
    {
    }

    event void RootDirectory.getRootDone(result_t res)
    {
    }

    event void RootDirectory.restore(flashptr_t *restore_ptr)
    {
        call Console.string("Restoring...\n");
    }

}

--- NEW FILE: sizes.h ---
#ifndef SIZES_H
#define SIZES_H

/*
 * Debug messages
 */

#define FLASH_DEBUG
//#define INDEX_DEBUG
//#define ARRAY_DEBUG
#define CHUNK_DEBUG
//#define QUEUE_DEBUG
//#define STACK_DEBUG
//#define STREAM_DEBUG
//#define STREAM_INDEX_DEBUG
//#define CHECKPOINT_DEBUG
//#define ROOT_DIR_DEBUG
//#define COMPACT_DEBUG
#define COUNT 20
/* Length of the data (compaction expt) */
#define LEN 20


//#define NUM_CHECKPOINTS 1 

/*
 * This indicates the number of elements in level 1 of the index
 */
#define ARRAY_ELEMENTS_PER_CHUNK 10

/*
 * This indicates the number of index elements in level 2 of the index
 */
#define INDEX_ELEMENTS_PER_CHUNK 10




#endif



More information about the Tinyos-contrib-commits mailing list