application.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * File : app.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2008-12-11 xuxinming the first version
  13. */
  14. #include <rtthread.h>
  15. /**
  16. * @addtogroup LPC2478
  17. */
  18. /*@{*/
  19. char thread1_stack[512];
  20. char thread2_stack[512];
  21. struct rt_thread thread1;
  22. struct rt_thread thread2;
  23. void thread1_entry(void* parameter)
  24. {
  25. int i;
  26. while (1)
  27. {
  28. for (i = 0; i < 10; i ++)
  29. {
  30. rt_kprintf("%d\n", i);
  31. rt_thread_delay(100);
  32. }
  33. }
  34. }
  35. void thread2_entry(void* parameter)
  36. {
  37. int count = 0;
  38. while (1)
  39. {
  40. rt_kprintf("Thread2 count:%d\n", count++);
  41. rt_thread_delay(50);
  42. }
  43. }
  44. int rt_application_init()
  45. {
  46. rt_thread_init(&thread1,
  47. "thread1",
  48. thread1_entry, RT_NULL,
  49. &thread1_stack[0], sizeof(thread1_stack),
  50. 20, 10);
  51. rt_thread_init(&thread2,
  52. "thread2",
  53. thread2_entry, RT_NULL,
  54. &thread2_stack[0], sizeof(thread2_stack),
  55. 25, 8);
  56. rt_thread_startup(&thread1);
  57. rt_thread_startup(&thread2);
  58. return 0;
  59. }
  60. /*@}*/