{"action":"created","issue":{"url":"https://api.github.com/repos/RT-Thread/rt-thread/issues/500","labels_url":"https://api.github.com/repos/RT-Thread/rt-thread/issues/500/labels{/name}","comments_url":"https://api.github.com/repos/RT-Thread/rt-thread/issues/500/comments","events_url":"https://api.github.com/repos/RT-Thread/rt-thread/issues/500/events","html_url":"https://github.com/RT-Thread/rt-thread/pull/500","id":86865744,"number":500,"title":"add support of rms","user":{"login":"hduffddybz","id":8110714,"avatar_url":"https://avatars.githubusercontent.com/u/8110714?v=3","gravatar_id":"","url":"https://api.github.com/users/hduffddybz","html_url":"https://github.com/hduffddybz","followers_url":"https://api.github.com/users/hduffddybz/followers","following_url":"https://api.github.com/users/hduffddybz/following{/other_user}","gists_url":"https://api.github.com/users/hduffddybz/gists{/gist_id}","starred_url":"https://api.github.com/users/hduffddybz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hduffddybz/subscriptions","organizations_url":"https://api.github.com/users/hduffddybz/orgs","repos_url":"https://api.github.com/users/hduffddybz/repos","events_url":"https://api.github.com/users/hduffddybz/events{/privacy}","received_events_url":"https://api.github.com/users/hduffddybz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-10T07:00:46Z","updated_at":"2015-06-10T07:57:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/RT-Thread/rt-thread/pulls/500","html_url":"https://github.com/RT-Thread/rt-thread/pull/500","diff_url":"https://github.com/RT-Thread/rt-thread/pull/500.diff","patch_url":"https://github.com/RT-Thread/rt-thread/pull/500.patch"},"body":"This is a very simple implementation of rms, it may not change the interface of \"task creation and so on\". So, you can use rm scheduling without any changes in your code.You can only use one rms task in one thread.\r\n\r\nPlease concern that #496  was a patch using for the correctness of timer which is related to rms.\r\nIf you want to use rms, please use \"#define RT_USING_RMS\" in your rtconfig.h, a very simple demo can list below:\r\n\r\n``` c\r\n\r\n#include <rtthread.h>\r\n \r\n#define THREAD_PRIORITY         25\r\n#define THREAD_STACK_SIZE    512\r\n#define THREAD_TIMESLICE       5\r\n \r\nstatic rt_thread_t tid1 = RT_NULL, tid2 = RT_NULL;\r\nstatic rt_rms_t rms1 = RT_NULL, rms2 = RT_NULL;\r\n \r\n\r\nstatic void thread_entry(void* parameter)\r\n{\r\n\trt_tick_t now, last, diff = 0;\r\n\tint a;\r\n\t\r\n\trms1 = rt_rms_create(\"rms1\");\r\n\tlast = rt_tick_get();\r\n\twhile(1)\r\n\t{\r\n        if(rt_rms_period(rms1, 10) != RT_EOK)\r\n        {\r\n            return;\r\n        }\r\n\t\tnow = rt_tick_get();\r\n\t\tdiff = now;\r\n\t\tdiff = diff - last;\r\n\t\tlast = now;\r\n\t\t\r\n\t\tfor(a = 0; a < 10000; a++);\r\n\t\t\r\n\t\trt_kprintf(\"thread1:%d\\n\", diff);\r\n   \t    if(rt_rms_delete(rms1) == RT_EOK)\r\n                break;\r\n \r\n\t}\r\n}\r\n \r\nstatic void thread2_entry(void* parameter)\r\n{\r\n\trt_tick_t now, last, diff = 0;\r\n\tint a;\r\n\t\r\n\trms2 = rt_rms_create(\"rms2\");\r\n\tlast = rt_tick_get();\r\n\twhile(1)\r\n\t{\r\n\t\tif(rt_rms_period(rms2, 20) != RT_EOK)\r\n\t\t{\r\n                    return;\r\n\t\t}\r\n\t\tnow = rt_tick_get();\r\n\t\tdiff = now;\r\n\t\tdiff = diff - last;\r\n\t\tlast = now;\r\n\t\t\r\n\t\tfor(a = 0; a < 100000; a++);\r\n \r\n\t\trt_kprintf(\"thread2:%d\\n\", diff);\r\n \r\n\t}\r\n}\r\n\r\nint rt_application_init()\r\n{\r\n\r\n    tid1 = rt_thread_create(\"t1\",\r\n        thread_entry, (void*)1, \r\n        THREAD_STACK_SIZE, THREAD_PRIORITY + 1, THREAD_TIMESLICE);\r\n    if (tid1 != RT_NULL)\r\n        rt_thread_startup(tid1);\r\n    else\r\n        return -1;\r\n \r\n    tid2 = rt_thread_create(\"t2\",\r\n\t\tthread2_entry, (void *)1,\r\n\t\tTHREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);\r\n    if(tid2 != RT_NULL)\r\n        rt_thread_startup(tid2);\r\n    else\r\n        return -1;\t\t\r\n \r\n    return 0;\r\n}\r\n\r\n```\r\n\r\nNotice that if some tasks exceed its deadline,what thing to do all depend on the application designer, you can delete task or just ignore it.\r\n\r\nRT-Thread  only support 256 level priorities, but you can set #define RT_RMS_ACCURACY 10(or any other number), so in this way, tasks with period of 11 ticks and 12 ticks can get the same priority."},"comment":{"url":"https://api.github.com/repos/RT-Thread/rt-thread/issues/comments/110642151","html_url":"https://github.com/RT-Thread/rt-thread/pull/500#issuecomment-110642151","issue_url":"https://api.github.com/repos/RT-Thread/rt-thread/issues/500","id":110642151,"user":{"login":"hduffddybz","id":8110714,"avatar_url":"https://avatars.githubusercontent.com/u/8110714?v=3","gravatar_id":"","url":"https://api.github.com/users/hduffddybz","html_url":"https://github.com/hduffddybz","followers_url":"https://api.github.com/users/hduffddybz/followers","following_url":"https://api.github.com/users/hduffddybz/following{/other_user}","gists_url":"https://api.github.com/users/hduffddybz/gists{/gist_id}","starred_url":"https://api.github.com/users/hduffddybz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hduffddybz/subscriptions","organizations_url":"https://api.github.com/users/hduffddybz/orgs","repos_url":"https://api.github.com/users/hduffddybz/repos","events_url":"https://api.github.com/users/hduffddybz/events{/privacy}","received_events_url":"https://api.github.com/users/hduffddybz/received_events","type":"User","site_admin":false},"created_at":"2015-06-10T07:57:16Z","updated_at":"2015-06-10T07:57:16Z","body":"#439 In this issue, we talk about 3 questions:\r\n\r\n1. How to handle aperiodic task in rm scheduling?\r\n\r\n2. How to deal with the scheduling analysis?\r\n\r\n3. When some tasks execute exceed deadline, how to deal with it?\r\n\r\nsome of my thoughts that time may not correct or just something in paper.So how to deal with this problem in this PR?\r\n\r\n1. How to handle aperiodic task in rm scheduling?\r\n\r\nall of the tasks including aperiodic and periodic can scheduled by their priority. The difference between them are that you can set the priority of aperiodic tasks manually, and in periodic task, the priority should set by their period.\r\n\r\n 2. How to deal with the scheduling analysis?\r\n\r\nthe analysis of scheduling should be done by application designer. It is really hard to implement this \"off-line\" tool. Some of researcher are interested in this topic.\r\n\r\n3. When some tasks execute exceed deadline, how to deal with it?\r\n\r\nWhat should do all depends on the application designer, you can delete this task or just ignore it and forbidden the creation of new tasks.\r\n\r\n"}}