Changeset 88a6819 in mainline for uspace/srv/net/tcp/test.c


Ignore:
Timestamp:
2012-05-08T08:18:48Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
99d05e1
Parents:
d21e935c
Message:

Use fibrils instead of threads for background work in TCP.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tcp/test.c

    rd21e935c r88a6819  
    3838#include <errno.h>
    3939#include <stdio.h>
    40 #include <thread.h>
     40#include <fibril.h>
    4141#include <str.h>
    4242#include "tcp_type.h"
     
    4747#define RCV_BUF_SIZE 64
    4848
    49 static void test_srv(void *arg)
     49static int test_srv(void *arg)
    5050{
    5151        tcp_conn_t *conn;
     
    8484
    8585        printf("test_srv() terminating\n");
     86        return 0;
    8687}
    8788
    88 static void test_cli(void *arg)
     89static int test_cli(void *arg)
    8990{
    9091        tcp_conn_t *conn;
     
    112113        printf("C: User close...\n");
    113114        tcp_uc_close(conn);
     115
     116        return 0;
    114117}
    115118
    116119void tcp_test(void)
    117120{
    118         thread_id_t srv_tid;
    119         thread_id_t cli_tid;
    120         int rc;
     121        fid_t srv_fid;
     122        fid_t cli_fid;
    121123
    122124        printf("tcp_test()\n");
     
    125127
    126128        if (0) {
    127                 rc = thread_create(test_srv, NULL, "test_srv", &srv_tid);
    128                 if (rc != EOK) {
    129                         printf("Failed to create server thread.\n");
     129                srv_fid = fibril_create(test_srv, NULL);
     130                if (srv_fid == 0) {
     131                        printf("Failed to create server fibril.\n");
    130132                        return;
    131133                }
     134
     135                fibril_add_ready(srv_fid);
    132136        }
    133137
    134138        if (0) {
    135                 rc = thread_create(test_cli, NULL, "test_cli", &cli_tid);
    136                 if (rc != EOK) {
    137                         printf("Failed to create client thread.\n");
     139                cli_fid = fibril_create(test_cli, NULL);
     140                if (cli_fid == 0) {
     141                        printf("Failed to create client fibril.\n");
    138142                        return;
    139143                }
     144
     145                fibril_add_ready(cli_fid);
    140146        }
    141147}
Note: See TracChangeset for help on using the changeset viewer.