Kannel: Open Source WAP and SMS gateway  svn-r5335
test_wakeup.c File Reference
#include <unistd.h>
#include "gwlib/gwlib.h"

Go to the source code of this file.

Functions

static void thread1 (void *arg)
 
static void thread2 (void *arg)
 
int main (void)
 

Function Documentation

◆ main()

int main ( void  )

Definition at line 85 of file test_wakeup.c.

References debug(), gwlib_init(), gwlib_shutdown(), gwthread_cancel(), gwthread_create, gwthread_join_all(), gwthread_wakeup(), gwthread_wakeup_all(), thread1(), and thread2().

86 {
87  pid_t pid;
88  long t1, t2;
89  int ret;
90 
91  gwlib_init();
92  pid = getpid();
93  debug("test", 0, "Parent pid %ld", (long)pid);
94  t1 = gwthread_create(thread1, NULL);
95  t2 = gwthread_create(thread2, NULL);
96  sleep(1);
97  gwthread_wakeup(t1);
98  ret = gwthread_cancel(t2);
99  debug("test", 0 ,"gwthread_cancel returns: %d", ret);
102  gwlib_shutdown();
103  return 0;
104 }
void gwthread_join_all(void)
static void thread2(void *arg)
Definition: test_wakeup.c:73
#define gwthread_create(func, arg)
Definition: gwthread.h:90
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
void gwthread_wakeup(long thread)
void gwlib_shutdown(void)
Definition: gwlib.c:94
void gwlib_init(void)
Definition: gwlib.c:78
int gwthread_cancel(long thread)
void gwthread_wakeup_all(void)
static void thread1(void *arg)
Definition: test_wakeup.c:61

◆ thread1()

static void thread1 ( void *  arg)
static

Definition at line 61 of file test_wakeup.c.

References debug(), and gwthread_sleep().

Referenced by main().

62 {
63  pid_t pid;
64 
65  debug("test", 0, "Sleeping");
66  pid = getpid();
67  debug("test", 0, "Thread1 pid %ld", (long)pid);
68 
69  gwthread_sleep(600);
70  debug("test", 0, "Woke up");
71 }
void gwthread_sleep(double seconds)
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726

◆ thread2()

static void thread2 ( void *  arg)
static

Definition at line 73 of file test_wakeup.c.

References debug(), and gwthread_sleep().

Referenced by main().

74 {
75  pid_t pid;
76 
77  debug("test", 0, "Sleeping");
78  pid = getpid();
79  debug("test", 0, "Thread2 pid %ld", (long)pid);
80 
81  gwthread_sleep(600);
82  debug("test", 0, "Woke up");
83 }
void gwthread_sleep(double seconds)
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.