In order to execute the program, hello.c, (after booting rtlinux, ofcourse) you must do the following :
include rtl.mk all: hello.o clean: rm -f *.o hello.o: hello.c $(CC) ${INCLUDE} ${CFLAGS} -c hello.c
$ make
$ rtlinux start hello
You should now be able to see your hello.o program printing its message every second. Depending on the configuration of your machine, you should either be able to see it directly in your console, or by typing:
$ dmesg
To stop the program, you need to remove it from the kernel. To do so, type:
$ rtlinux stop hello
Alternate ways for inserting and removing the module is to use insmod and rmmod respectively.
Here, we have made our example program too simple. Contrary to what we have seen, there may be multiple threads in a program. Priority can be set at thread creation or modified later. Also, we can select the scheduling algorithm that should be used. In fact, we can write our own scheduling algorithms!
In our example, we can set priority of the thread as 1, and select FIFO scheduling by inserting the following lines in the beginning of the function, thread_code() :
struct sched_param p; p . sched_priority = 1; pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |