demo.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:2k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* demo.c - a program to demonstrate multitasking under vxWorks */
  2. /* Copyright 1984-1993 Wind River Systems, Inc. */
  3. #include "copyright_wrs.h"
  4. /*
  5. modification history
  6. --------------------
  7. 01j,13feb93,jcf  cleaned.
  8. 01i,31oct91,rrr  passed through the ansification filter
  9.   -changed VOID to void
  10.   -changed copyright notice
  11. 01h,26aug88,gae  made it print the task id and name.
  12. 01g,22jun88,dnw  name tweaks.
  13. 01f,30may88,dnw  changed to v4 names.
  14. 01e,15mar88,jcf  changed vxMyTaskId to taskId.
  15.                  removed include of vxLib.h
  16. 01d,03mar87,dnw  changed myTaskId to vxMyTaskId.
  17. 01c,08jan87,jlf  minor cleanup.
  18.  changed <> to " in includes.
  19. 01b,12nov86,jlf  use myTaskId instead of vxTinquiry for clarity.
  20. 01a,14aug84,jlf  written
  21. */
  22. /*
  23. DESCRIPTION
  24. This routine prints its task id and name and its startup parameter.
  25. Is is for demonstration purposes.  It may be spawned, run
  26. periodically, or called directly from the shell.
  27. EXAMPLE
  28. The following is an example from the VxWorks shell:
  29.     -> ld 1 <demo.o
  30.     value = 0 = 0x0
  31.     -> demo
  32.     Hello from task 0x3d6cac (shell). Startup parameter was 0.
  33.     value = 2 = 0x2
  34.     -> sp demo, $10
  35.     task spawned: id = 0x3c96d8, name = 1
  36.     value = 3970776 = 0x3c96d8
  37.     -> Hello from task 0x3c96d8 (1). Startup parameter was 16.
  38.     -> repeat 4, demo, $a
  39.     task spawned: id = 0x3c96d8, name = 2
  40.     value = 0 = 0x0
  41.     -> Hello from task 0x3c96d8 (2). Startup parameter was 10.
  42.     Hello from task 0x3c96d8 (2). Startup parameter was 10.
  43.     Hello from task 0x3c96d8 (2). Startup parameter was 10.
  44.     Hello from task 0x3c96d8 (2). Startup parameter was 10.
  45.     ->
  46. SEE ALSO: "Getting Started"
  47. */
  48. #include "vxWorks.h"
  49. #include "taskLib.h"
  50. #include "stdio.h"
  51. /*******************************************************************************
  52. *
  53. * demo - a simple demo routine
  54. *
  55. * This routine prints its task id and name and startup parameter.
  56. */
  57. void demo (param)
  58.     int param;
  59.     {
  60.     /* find out what task we are, and print message */
  61.     printf ("Hello from task %#x (%s). Startup parameter was %d.n",
  62.     taskIdSelf (), taskName (taskIdSelf()), param);
  63.     }