{"action":"created","issue":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5296","repository_url":"https://api.github.com/repos/RIOT-OS/RIOT","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5296/labels{/name}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5296/comments","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5296/events","html_url":"https://github.com/RIOT-OS/RIOT/issues/5296","id":147542599,"number":5296,"title":"core: create message queue on thread creation","user":{"login":"OlegHahm","id":1590423,"avatar_url":"https://avatars.githubusercontent.com/u/1590423?v=3","gravatar_id":"","url":"https://api.github.com/users/OlegHahm","html_url":"https://github.com/OlegHahm","followers_url":"https://api.github.com/users/OlegHahm/followers","following_url":"https://api.github.com/users/OlegHahm/following{/other_user}","gists_url":"https://api.github.com/users/OlegHahm/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegHahm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegHahm/subscriptions","organizations_url":"https://api.github.com/users/OlegHahm/orgs","repos_url":"https://api.github.com/users/OlegHahm/repos","events_url":"https://api.github.com/users/OlegHahm/events{/privacy}","received_events_url":"https://api.github.com/users/OlegHahm/received_events","type":"User","site_admin":false},"labels":[{"id":165479578,"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/Feature%20Request","name":"Feature Request","color":"aefdcb","default":false},{"id":100135107,"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/Request%20for%20Comments","name":"Request for Comments","color":"23F823","default":false}],"state":"open","locked":false,"assignee":{"login":"kaspar030","id":4679640,"avatar_url":"https://avatars.githubusercontent.com/u/4679640?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspar030","html_url":"https://github.com/kaspar030","followers_url":"https://api.github.com/users/kaspar030/followers","following_url":"https://api.github.com/users/kaspar030/following{/other_user}","gists_url":"https://api.github.com/users/kaspar030/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspar030/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspar030/subscriptions","organizations_url":"https://api.github.com/users/kaspar030/orgs","repos_url":"https://api.github.com/users/kaspar030/repos","events_url":"https://api.github.com/users/kaspar030/events{/privacy}","received_events_url":"https://api.github.com/users/kaspar030/received_events","type":"User","site_admin":false},"assignees":[{"login":"kaspar030","id":4679640,"avatar_url":"https://avatars.githubusercontent.com/u/4679640?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspar030","html_url":"https://github.com/kaspar030","followers_url":"https://api.github.com/users/kaspar030/followers","following_url":"https://api.github.com/users/kaspar030/following{/other_user}","gists_url":"https://api.github.com/users/kaspar030/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspar030/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspar030/subscriptions","organizations_url":"https://api.github.com/users/kaspar030/orgs","repos_url":"https://api.github.com/users/kaspar030/repos","events_url":"https://api.github.com/users/kaspar030/events{/privacy}","received_events_url":"https://api.github.com/users/kaspar030/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2016-04-11T20:15:56Z","updated_at":"2016-11-18T12:52:04Z","closed_at":null,"body":"Currently, a thread has to create its own message queue. This could lead to an ugly situation, where a thread is created (via `thread_create()`) with a lower priority and other threads (all with higher priorities) start already sending IPC messages to the new thread. Even if the thread would call `msg_init_queue()`, this won't be called in time and messages will get lost (if non-blocking IPC calls are used).\n\nThere are two ways to go about this:\n1.) Leave it as is and consider this a design decision. This would, for instance, make it impossible to create a GNRC thread with a lower priority and register it after creation from the creating thread.\n2.) Add a parameter to `thread_create()` to pass a message queue right on thread creation. (Or provide a function to create message queues for other threads.)\n\nThanks @tfar for reporting this issue.\n"},"comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/comments/261524876","html_url":"https://github.com/RIOT-OS/RIOT/issues/5296#issuecomment-261524876","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5296","id":261524876,"user":{"login":"kaspar030","id":4679640,"avatar_url":"https://avatars.githubusercontent.com/u/4679640?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspar030","html_url":"https://github.com/kaspar030","followers_url":"https://api.github.com/users/kaspar030/followers","following_url":"https://api.github.com/users/kaspar030/following{/other_user}","gists_url":"https://api.github.com/users/kaspar030/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspar030/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspar030/subscriptions","organizations_url":"https://api.github.com/users/kaspar030/orgs","repos_url":"https://api.github.com/users/kaspar030/repos","events_url":"https://api.github.com/users/kaspar030/events{/privacy}","received_events_url":"https://api.github.com/users/kaspar030/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T12:52:04Z","updated_at":"2016-11-18T12:52:04Z","body":">> one thread registering another is extremely bad design\r\n> Can you elaborate on this?\r\n\r\nMaybe \"extremely bad design\" is exaggerated, but a thread gets \"registered\" for something by another thread, the thread has no control over when it get's registered, and it might not be ready. It might even have preconditions that are not met and decide not to register at all. I can't quote any book here, but IMHO having a thread deal with it's own stuff makes the overall design much cleaner.\r\n\r\nI think the example you've given in the PR description shows such a problem that could have been avoided:\r\n\r\n\"This could lead to an ugly situation, where a thread is created (via thread_create()) with a lower priority and other threads (all with higher priorities) start already sending IPC messages to the new thread. Even if the thread would call msg_init_queue(), this won't be called in time and messages will get lost (if non-blocking IPC calls are used).\"\r\n\r\n(I assume that other threads only start sending IPC messages *after* the thread has been registered for receiving them.)\r\n"}}
{"actor":{"display_login":"kaspar030"}}