Changeset 9591265 in mainline


Ignore:
Timestamp:
2007-06-28T19:45:36Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f2f0392
Parents:
12f91130
Message:

More psthread/fibril cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/async.c

    r12f91130 r9591265  
    3636 * Asynchronous library
    3737 *
    38  * The aim of this library is facilitating writing programs utilizing
    39  * the asynchronous nature of HelenOS IPC, yet using a normal way
    40  * of programming.
    41  *
    42  * You should be able to write very simple multithreaded programs,
    43  * the async framework will automatically take care of most synchronization
    44  * problems.
     38 * The aim of this library is facilitating writing programs utilizing the
     39 * asynchronous nature of HelenOS IPC, yet using a normal way of programming.
     40 *
     41 * You should be able to write very simple multithreaded programs, the async
     42 * framework will automatically take care of most synchronization problems.
    4543 *
    4644 * Default semantics:
    47  * - send() - send asynchronously. If the kernel refuses to send more
    48  *            messages, [ try to get responses from kernel, if nothing
    49  *           found, might try synchronous ]
    50  *
    51  * Example of use:
     45 * - async_send_*():    send asynchronously. If the kernel refuses to send
     46 *                      more messages, [ try to get responses from kernel, if
     47 *                      nothing found, might try synchronous ]
     48 *
     49 * Example of use (pseudo C):
    5250 *
    5351 * 1) Multithreaded client application
    54  *  fibril_create(fibril1);
    55  *  fibril_create(fibril2);
    56  *  ...
     52 *
     53 * fibril_create(fibril1, ...);
     54 * fibril_create(fibril2, ...);
     55 * ...
    5756 * 
    58  *  fibril1() {
    59  *        conn = ipc_connect_me_to();
    60  *        c1 = send(conn);
    61  *        c2 = send(conn);
    62  *        wait_for(c1);
    63  *        wait_for(c2);
    64  *  }
     57 * int fibril1(void *arg)
     58 * {
     59 *      conn = ipc_connect_me_to();
     60 *      c1 = async_send(conn);
     61 *      c2 = async_send(conn);
     62 *      async_wait_for(c1);
     63 *      async_wait_for(c2);
     64 *      ...
     65 * }
    6566 *
    6667 *
    6768 * 2) Multithreaded server application
    68  * main() {
    69  *      async_manager();
     69 * main()
     70 * {
     71 *      async_manager();
    7072 * }
    7173 *
    7274 *
    73  * client_connection(icallid, *icall) {
    74  *       if (want_refuse) {
    75  *           ipc_answer_fast(icallid, ELIMIT, 0, 0);
    76  *           return;
    77  *       }
    78  *       ipc_answer_fast(icallid, 0, 0, 0);
    79  *
    80  *       callid = async_get_call(&call);
    81  *       handle(callid, call);
    82  *       ipc_answer_fast(callid, 1, 2, 3);
    83  *
    84  *       callid = async_get_call(&call);
    85  *       ....
     75 * client_connection(icallid, *icall)
     76 * {
     77 *      if (want_refuse) {
     78 *              ipc_answer_fast(icallid, ELIMIT, 0, 0);
     79 *              return;
     80 *      }
     81 *      ipc_answer_fast(icallid, EOK, 0, 0);
     82 *
     83 *      callid = async_get_call(&call);
     84 *      handle_call(callid, call);
     85 *      ipc_answer_fast(callid, 1, 2, 3);
     86 *
     87 *      callid = async_get_call(&call);
     88 *      ....
    8689 * }
    8790 *
    8891 */
     92
    8993#include <futex.h>
    9094#include <async.h>
     
    568572 * exist per thread. The particular implementation may change,
    569573 * currently one async_manager is started automatically per kernel
    570  * thread except main thread.
    571  */
    572 static int async_manager_thread(void *arg)
     574 * thread except the main thread.
     575 */
     576static int async_manager_fibril(void *arg)
    573577{
    574578        futex_up(&async_futex);
     
    585589        fid_t fid;
    586590
    587         fid = fibril_create(async_manager_thread, NULL);
     591        fid = fibril_create(async_manager_fibril, NULL);
    588592        fibril_add_manager(fid);
    589593}
Note: See TracChangeset for help on using the changeset viewer.