Homework2_3Multithreads_YuwenSun

Dependencies:   mbed

Committer:
sun831011
Date:
Tue Nov 30 22:19:29 2010 +0000
Revision:
0:edab293d7652

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sun831011 0:edab293d7652 1 /*
sun831011 0:edab293d7652 2 * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
sun831011 0:edab293d7652 3 * All rights reserved.
sun831011 0:edab293d7652 4 *
sun831011 0:edab293d7652 5 * Redistribution and use in source and binary forms, with or without
sun831011 0:edab293d7652 6 * modification, are permitted provided that the following conditions
sun831011 0:edab293d7652 7 * are met:
sun831011 0:edab293d7652 8 * 1. Redistributions of source code must retain the above copyright
sun831011 0:edab293d7652 9 * notice, this list of conditions and the following disclaimer.
sun831011 0:edab293d7652 10 * 2. Redistributions in binary form must reproduce the above copyright
sun831011 0:edab293d7652 11 * notice, this list of conditions and the following disclaimer in the
sun831011 0:edab293d7652 12 * documentation and/or other materials provided with the distribution.
sun831011 0:edab293d7652 13 * 3. Neither the name of the Institute nor the names of its contributors
sun831011 0:edab293d7652 14 * may be used to endorse or promote products derived from this software
sun831011 0:edab293d7652 15 * without specific prior written permission.
sun831011 0:edab293d7652 16 *
sun831011 0:edab293d7652 17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
sun831011 0:edab293d7652 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sun831011 0:edab293d7652 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sun831011 0:edab293d7652 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
sun831011 0:edab293d7652 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sun831011 0:edab293d7652 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sun831011 0:edab293d7652 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sun831011 0:edab293d7652 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sun831011 0:edab293d7652 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sun831011 0:edab293d7652 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sun831011 0:edab293d7652 27 * SUCH DAMAGE.
sun831011 0:edab293d7652 28 *
sun831011 0:edab293d7652 29 * This file is part of the protothreads library.
sun831011 0:edab293d7652 30 *
sun831011 0:edab293d7652 31 * Author: Adam Dunkels <adam@sics.se>
sun831011 0:edab293d7652 32 *
sun831011 0:edab293d7652 33 * $Id: lc.h,v 1.2 2005/02/24 10:36:59 adam Exp $
sun831011 0:edab293d7652 34 */
sun831011 0:edab293d7652 35
sun831011 0:edab293d7652 36 /**
sun831011 0:edab293d7652 37 * \addtogroup pt
sun831011 0:edab293d7652 38 * @{
sun831011 0:edab293d7652 39 */
sun831011 0:edab293d7652 40
sun831011 0:edab293d7652 41 /**
sun831011 0:edab293d7652 42 * \defgroup lc Local continuations
sun831011 0:edab293d7652 43 * @{
sun831011 0:edab293d7652 44 *
sun831011 0:edab293d7652 45 * Local continuations form the basis for implementing protothreads. A
sun831011 0:edab293d7652 46 * local continuation can be <i>set</i> in a specific function to
sun831011 0:edab293d7652 47 * capture the state of the function. After a local continuation has
sun831011 0:edab293d7652 48 * been set can be <i>resumed</i> in order to restore the state of the
sun831011 0:edab293d7652 49 * function at the point where the local continuation was set.
sun831011 0:edab293d7652 50 *
sun831011 0:edab293d7652 51 *
sun831011 0:edab293d7652 52 */
sun831011 0:edab293d7652 53
sun831011 0:edab293d7652 54 /**
sun831011 0:edab293d7652 55 * \file lc.h
sun831011 0:edab293d7652 56 * Local continuations
sun831011 0:edab293d7652 57 * \author
sun831011 0:edab293d7652 58 * Adam Dunkels <adam@sics.se>
sun831011 0:edab293d7652 59 *
sun831011 0:edab293d7652 60 */
sun831011 0:edab293d7652 61
sun831011 0:edab293d7652 62 #ifdef DOXYGEN
sun831011 0:edab293d7652 63 /**
sun831011 0:edab293d7652 64 * Initialize a local continuation.
sun831011 0:edab293d7652 65 *
sun831011 0:edab293d7652 66 * This operation initializes the local continuation, thereby
sun831011 0:edab293d7652 67 * unsetting any previously set continuation state.
sun831011 0:edab293d7652 68 *
sun831011 0:edab293d7652 69 * \hideinitializer
sun831011 0:edab293d7652 70 */
sun831011 0:edab293d7652 71 #define LC_INIT(lc)
sun831011 0:edab293d7652 72
sun831011 0:edab293d7652 73 /**
sun831011 0:edab293d7652 74 * Set a local continuation.
sun831011 0:edab293d7652 75 *
sun831011 0:edab293d7652 76 * The set operation saves the state of the function at the point
sun831011 0:edab293d7652 77 * where the operation is executed. As far as the set operation is
sun831011 0:edab293d7652 78 * concerned, the state of the function does <b>not</b> include the
sun831011 0:edab293d7652 79 * call-stack or local (automatic) variables, but only the program
sun831011 0:edab293d7652 80 * counter and such CPU registers that needs to be saved.
sun831011 0:edab293d7652 81 *
sun831011 0:edab293d7652 82 * \hideinitializer
sun831011 0:edab293d7652 83 */
sun831011 0:edab293d7652 84 #define LC_SET(lc)
sun831011 0:edab293d7652 85
sun831011 0:edab293d7652 86 /**
sun831011 0:edab293d7652 87 * Resume a local continuation.
sun831011 0:edab293d7652 88 *
sun831011 0:edab293d7652 89 * The resume operation resumes a previously set local continuation, thus
sun831011 0:edab293d7652 90 * restoring the state in which the function was when the local
sun831011 0:edab293d7652 91 * continuation was set. If the local continuation has not been
sun831011 0:edab293d7652 92 * previously set, the resume operation does nothing.
sun831011 0:edab293d7652 93 *
sun831011 0:edab293d7652 94 * \hideinitializer
sun831011 0:edab293d7652 95 */
sun831011 0:edab293d7652 96 #define LC_RESUME(lc)
sun831011 0:edab293d7652 97
sun831011 0:edab293d7652 98 /**
sun831011 0:edab293d7652 99 * Mark the end of local continuation usage.
sun831011 0:edab293d7652 100 *
sun831011 0:edab293d7652 101 * The end operation signifies that local continuations should not be
sun831011 0:edab293d7652 102 * used any more in the function. This operation is not needed for
sun831011 0:edab293d7652 103 * most implementations of local continuation, but is required by a
sun831011 0:edab293d7652 104 * few implementations.
sun831011 0:edab293d7652 105 *
sun831011 0:edab293d7652 106 * \hideinitializer
sun831011 0:edab293d7652 107 */
sun831011 0:edab293d7652 108 #define LC_END(lc)
sun831011 0:edab293d7652 109
sun831011 0:edab293d7652 110 /**
sun831011 0:edab293d7652 111 * \var typedef lc_t;
sun831011 0:edab293d7652 112 *
sun831011 0:edab293d7652 113 * The local continuation type.
sun831011 0:edab293d7652 114 *
sun831011 0:edab293d7652 115 * \hideinitializer
sun831011 0:edab293d7652 116 */
sun831011 0:edab293d7652 117 #endif /* DOXYGEN */
sun831011 0:edab293d7652 118
sun831011 0:edab293d7652 119 #ifndef __LC_H__
sun831011 0:edab293d7652 120 #define __LC_H__
sun831011 0:edab293d7652 121
sun831011 0:edab293d7652 122
sun831011 0:edab293d7652 123 #ifdef LC_INCLUDE
sun831011 0:edab293d7652 124 #include LC_INCLUDE
sun831011 0:edab293d7652 125 #else
sun831011 0:edab293d7652 126 #include "lc-switch.h"
sun831011 0:edab293d7652 127 #endif /* LC_INCLUDE */
sun831011 0:edab293d7652 128
sun831011 0:edab293d7652 129 #endif /* __LC_H__ */
sun831011 0:edab293d7652 130
sun831011 0:edab293d7652 131 /** @} */
sun831011 0:edab293d7652 132 /** @} */