{"action":"created","comment":{"url":"https://api.github.com/repos/gedare/rtems/pulls/comments/174636383","pull_request_review_id":104029704,"id":174636383,"diff_hunk":"@@ -0,0 +1,184 @@\n+/*\n+ * Thread Priority Node\n+ * \n+ * Copyright (C) 2017. Gedare Bloom and Samman Bikram Thapa.\n+ *\n+ * The license and distribution terms for this file may be\n+ * found in the file LICENSE in this distribution or at\n+ * http://www.rtems.org/license/LICENSE.\n+ */\n+\n+#if HAVE_CONFIG_H\n+#include \"config.h\"\n+#endif\n+\n+#include <rtems/system.h>\n+#include <rtems/config.h>\n+#include <rtems/score/chain.h>\n+#include <rtems/score/coremutex.h>\n+#include <rtems/score/coremuteximpl.h>\n+#include <rtems/score/thread.h>\n+#include <rtems/score/threadimpl.h>\n+\n+/**\n+ * This routine adds a thread's Priority_node to the mutex holder's\n+ * Inherited_priorities list, and sets the waiting_to_hold field to the\n+ * mutex.\n+ *\n+ * Returns true if the enqueued node is at the head of the holder's\n+ * Inherited priorities, and therefore the holder's priority may change.\n+ */\n+bool _Thread_Enqueue_priority_node(\n+  Thread_Control     *the_thread,\n+  CORE_mutex_Control *the_mutex\n+)\n+{\n+  Chain_Node *iter;\n+  Thread_Priority_node *thread_pn, *holder_pn;\n+  Priority_Control task_priority, iter_priority;\n+  \n+  thread_pn = &the_thread->Priority_node;\n+  holder_pn = &the_mutex->holder->Priority_node;\n+\n+  thread_pn->waiting_to_hold = the_mutex;\n+  iter = _Chain_First( &holder_pn->Inherited_priorities );\n+  task_priority = thread_pn->current_priority;\n+\n+  /* Find the first node in holder's Inherited_priorities list with\n+   * lower priority than the task, or find the end of the list. */\n+  while ( !_Chain_Is_tail( &holder_pn->Inherited_priorities, iter) ) {\n+    iter_priority = ((Thread_Priority_node *)iter)->current_priority;\n+    if ( iter_priority > task_priority ) {\n+      break;\n+    }\n+    iter = _Chain_Next( iter );\n+  }\n+  _Chain_Insert_unprotected( _Chain_Previous( iter ), &thread_pn->Node );\n+\n+  /* If the_thread is at the start of the holder's Inherited_priorites list,\n+   * then may need to update the holder's current priority. */\n+  if ( _Chain_Is_first( &thread_pn->Node ) ) {\n+    return true;\n+  }\n+  return false;\n+}\n+\n+/**\n+ * This routine sets the thread's priority_node->current_priority to the\n+ * minimum of the real_priority and the first node of Inherited_priorities,\n+ * if any.\n+ */\n+void _Thread_Evaluate_priority(\n+  Thread_Control *the_thread\n+)\n+{\n+  Chain_Node *first;\n+  Thread_Priority_node *first_pn, *priority_node;\n+  Priority_Control current_priority, min_priority;\n+\n+  /* Start with the_thread, and iterate through the holder threads that\n+   * the_thread is waiting on. If any thread's priority does not change,\n+   * then stop iterating. */\n+  while ( the_thread != NULL ) {\n+    priority_node = &the_thread->Priority_node;\n+    current_priority = priority_node->current_priority;\n+    min_priority = priority_node->real_priority;\n+    first = _Chain_First( &priority_node->Inherited_priorities );\n+    if ( !_Chain_Is_tail( &priority_node->Inherited_priorities, first ) ) {\n+      first_pn = (Thread_Priority_node *)first;\n+      if ( min_priority > first_pn->current_priority ) {\n+        min_priority = first_pn->current_priority;\n+      }\n+    }\n+    if ( current_priority < min_priority ) {\n+        _Thread_Restore_priority(\n+                the_thread\n+                );\n+    } else if ( current_priority > min_priority ) {\n+        _Thread_Raise_priority(\n+                the_thread,\n+                min_priority\n+                );\n+    } else {\n+      break;\n+    }\n+    if ( the_thread->Priority_node.waiting_to_hold != NULL ) {\n+      the_thread = the_thread->Priority_node.waiting_to_hold->holder;\n+    } else {\n+      the_thread = NULL;\n+    }\n+  }\n+}\n+\n+/**\n+ * This routine removes a thread's Priority_node from an\n+ * Inherited_priorities list, updates the mutex holder's\n+ * current_priority if needed, and clears the mutex field.\n+ *\n+ * Returns the mutex that the_thread was waiting on.\n+ */\n+CORE_mutex_Control* _Thread_Dequeue_priority_node(\n+  Thread_Priority_node *thread_pn\n+)\n+{\n+  CORE_mutex_Control *the_mutex = thread_pn->waiting_to_hold;\n+\n+  if ( the_mutex == NULL ) {\n+    return NULL;\n+  }\n+\n+  _Chain_Extract_unprotected( &thread_pn->Node );\n+  thread_pn->waiting_to_hold = NULL;\n+\n+  return the_mutex;\n+}\n+\n+void _Thread_Requeue_priority_node(\n+  Thread_Control *the_thread\n+)\n+{\n+  ISR_Level       level;\n+  CORE_mutex_Control *mutex;\n+  bool mutex_owner_needs_update;\n+\n+  _ISR_Disable( level );\n+  /* TODO: refactor? */\n+  /* We are merely removing the priority node from \n+   * OwnerThread.Inherited_priorities\n+   * and readding the the_thread->Priority_node back\n+   */\n+  mutex = _Thread_Dequeue_priority_node( &the_thread->Priority_node );\n+  if ( mutex != NULL ) {\n+    mutex_owner_needs_update = _Thread_Enqueue_priority_node( the_thread, mutex\n+            );\n+    /* Samman TODO: Should not we update mutex.current_priority? */","path":"cpukit/score/src/threadprioritynode.c","position":154,"original_position":154,"commit_id":"d639bc5a7b2d9d1fdb841d8083b8ebe9a6bdc116","original_commit_id":"d639bc5a7b2d9d1fdb841d8083b8ebe9a6bdc116","user":{"login":"sammanthp007","id":8939811,"avatar_url":"https://avatars0.githubusercontent.com/u/8939811?v=4","gravatar_id":"","url":"https://api.github.com/users/sammanthp007","html_url":"https://github.com/sammanthp007","followers_url":"https://api.github.com/users/sammanthp007/followers","following_url":"https://api.github.com/users/sammanthp007/following{/other_user}","gists_url":"https://api.github.com/users/sammanthp007/gists{/gist_id}","starred_url":"https://api.github.com/users/sammanthp007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammanthp007/subscriptions","organizations_url":"https://api.github.com/users/sammanthp007/orgs","repos_url":"https://api.github.com/users/sammanthp007/repos","events_url":"https://api.github.com/users/sammanthp007/events{/privacy}","received_events_url":"https://api.github.com/users/sammanthp007/received_events","type":"User","site_admin":false},"body":"Oops.. that should not be there.","created_at":"2018-03-14T23:04:57Z","updated_at":"2018-03-14T23:04:57Z","html_url":"https://github.com/gedare/rtems/pull/1#discussion_r174636383","pull_request_url":"https://api.github.com/repos/gedare/rtems/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/gedare/rtems/pulls/comments/174636383"},"html":{"href":"https://github.com/gedare/rtems/pull/1#discussion_r174636383"},"pull_request":{"href":"https://api.github.com/repos/gedare/rtems/pulls/1"}},"in_reply_to_id":174633175},"pull_request":{"url":"https://api.github.com/repos/gedare/rtems/pulls/1","id":174867882,"html_url":"https://github.com/gedare/rtems/pull/1","diff_url":"https://github.com/gedare/rtems/pull/1.diff","patch_url":"https://github.com/gedare/rtems/pull/1.patch","issue_url":"https://api.github.com/repos/gedare/rtems/issues/1","number":1,"state":"open","locked":false,"title":"Improved priority inheritance implementation","user":{"login":"sammanthp007","id":8939811,"avatar_url":"https://avatars0.githubusercontent.com/u/8939811?v=4","gravatar_id":"","url":"https://api.github.com/users/sammanthp007","html_url":"https://github.com/sammanthp007","followers_url":"https://api.github.com/users/sammanthp007/followers","following_url":"https://api.github.com/users/sammanthp007/following{/other_user}","gists_url":"https://api.github.com/users/sammanthp007/gists{/gist_id}","starred_url":"https://api.github.com/users/sammanthp007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammanthp007/subscriptions","organizations_url":"https://api.github.com/users/sammanthp007/orgs","repos_url":"https://api.github.com/users/sammanthp007/repos","events_url":"https://api.github.com/users/sammanthp007/events{/privacy}","received_events_url":"https://api.github.com/users/sammanthp007/received_events","type":"User","site_admin":false},"body":"- [x] Implement the requirements of [this ticker](https://devel.rtems.org/ticket/2412) in RTEMS 4.11","created_at":"2018-03-14T06:54:00Z","updated_at":"2018-03-14T23:04:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0869bf0583ff5216c0d276bfb2010ac9de919a4b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/gedare/rtems/pulls/1/commits","review_comments_url":"https://api.github.com/repos/gedare/rtems/pulls/1/comments","review_comment_url":"https://api.github.com/repos/gedare/rtems/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gedare/rtems/issues/1/comments","statuses_url":"https://api.github.com/repos/gedare/rtems/statuses/d639bc5a7b2d9d1fdb841d8083b8ebe9a6bdc116","head":{"label":"sammanthp007:4.11-pip","ref":"4.11-pip","sha":"d639bc5a7b2d9d1fdb841d8083b8ebe9a6bdc116","user":{"login":"sammanthp007","id":8939811,"avatar_url":"https://avatars0.githubusercontent.com/u/8939811?v=4","gravatar_id":"","url":"https://api.github.com/users/sammanthp007","html_url":"https://github.com/sammanthp007","followers_url":"https://api.github.com/users/sammanthp007/followers","following_url":"https://api.github.com/users/sammanthp007/following{/other_user}","gists_url":"https://api.github.com/users/sammanthp007/gists{/gist_id}","starred_url":"https://api.github.com/users/sammanthp007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammanthp007/subscriptions","organizations_url":"https://api.github.com/users/sammanthp007/orgs","repos_url":"https://api.github.com/users/sammanthp007/repos","events_url":"https://api.github.com/users/sammanthp007/events{/privacy}","received_events_url":"https://api.github.com/users/sammanthp007/received_events","type":"User","site_admin":false},"repo":{"id":118472773,"name":"rtems","full_name":"sammanthp007/rtems","owner":{"login":"sammanthp007","id":8939811,"avatar_url":"https://avatars0.githubusercontent.com/u/8939811?v=4","gravatar_id":"","url":"https://api.github.com/users/sammanthp007","html_url":"https://github.com/sammanthp007","followers_url":"https://api.github.com/users/sammanthp007/followers","following_url":"https://api.github.com/users/sammanthp007/following{/other_user}","gists_url":"https://api.github.com/users/sammanthp007/gists{/gist_id}","starred_url":"https://api.github.com/users/sammanthp007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammanthp007/subscriptions","organizations_url":"https://api.github.com/users/sammanthp007/orgs","repos_url":"https://api.github.com/users/sammanthp007/repos","events_url":"https://api.github.com/users/sammanthp007/events{/privacy}","received_events_url":"https://api.github.com/users/sammanthp007/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sammanthp007/rtems","description":"Kernel, networking, file-systems, drivers, BSPs, samples, and testsuite.","fork":true,"url":"https://api.github.com/repos/sammanthp007/rtems","forks_url":"https://api.github.com/repos/sammanthp007/rtems/forks","keys_url":"https://api.github.com/repos/sammanthp007/rtems/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sammanthp007/rtems/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sammanthp007/rtems/teams","hooks_url":"https://api.github.com/repos/sammanthp007/rtems/hooks","issue_events_url":"https://api.github.com/repos/sammanthp007/rtems/issues/events{/number}","events_url":"https://api.github.com/repos/sammanthp007/rtems/events","assignees_url":"https://api.github.com/repos/sammanthp007/rtems/assignees{/user}","branches_url":"https://api.github.com/repos/sammanthp007/rtems/branches{/branch}","tags_url":"https://api.github.com/repos/sammanthp007/rtems/tags","blobs_url":"https://api.github.com/repos/sammanthp007/rtems/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sammanthp007/rtems/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sammanthp007/rtems/git/refs{/sha}","trees_url":"https://api.github.com/repos/sammanthp007/rtems/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sammanthp007/rtems/statuses/{sha}","languages_url":"https://api.github.com/repos/sammanthp007/rtems/languages","stargazers_url":"https://api.github.com/repos/sammanthp007/rtems/stargazers","contributors_url":"https://api.github.com/repos/sammanthp007/rtems/contributors","subscribers_url":"https://api.github.com/repos/sammanthp007/rtems/subscribers","subscription_url":"https://api.github.com/repos/sammanthp007/rtems/subscription","commits_url":"https://api.github.com/repos/sammanthp007/rtems/commits{/sha}","git_commits_url":"https://api.github.com/repos/sammanthp007/rtems/git/commits{/sha}","comments_url":"https://api.github.com/repos/sammanthp007/rtems/comments{/number}","issue_comment_url":"https://api.github.com/repos/sammanthp007/rtems/issues/comments{/number}","contents_url":"https://api.github.com/repos/sammanthp007/rtems/contents/{+path}","compare_url":"https://api.github.com/repos/sammanthp007/rtems/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sammanthp007/rtems/merges","archive_url":"https://api.github.com/repos/sammanthp007/rtems/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sammanthp007/rtems/downloads","issues_url":"https://api.github.com/repos/sammanthp007/rtems/issues{/number}","pulls_url":"https://api.github.com/repos/sammanthp007/rtems/pulls{/number}","milestones_url":"https://api.github.com/repos/sammanthp007/rtems/milestones{/number}","notifications_url":"https://api.github.com/repos/sammanthp007/rtems/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sammanthp007/rtems/labels{/name}","releases_url":"https://api.github.com/repos/sammanthp007/rtems/releases{/id}","deployments_url":"https://api.github.com/repos/sammanthp007/rtems/deployments","created_at":"2018-01-22T15:05:04Z","updated_at":"2018-01-22T15:05:34Z","pushed_at":"2018-03-14T06:49:30Z","git_url":"git://github.com/sammanthp007/rtems.git","ssh_url":"git@github.com:sammanthp007/rtems.git","clone_url":"https://github.com/sammanthp007/rtems.git","svn_url":"https://github.com/sammanthp007/rtems","homepage":"http://git.rtems.org/rtems/","size":111783,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gedare:4.11-pip","ref":"4.11-pip","sha":"119bdebd37314672c66cb41f890db2e60640436c","user":{"login":"gedare","id":1657385,"avatar_url":"https://avatars2.githubusercontent.com/u/1657385?v=4","gravatar_id":"","url":"https://api.github.com/users/gedare","html_url":"https://github.com/gedare","followers_url":"https://api.github.com/users/gedare/followers","following_url":"https://api.github.com/users/gedare/following{/other_user}","gists_url":"https://api.github.com/users/gedare/gists{/gist_id}","starred_url":"https://api.github.com/users/gedare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gedare/subscriptions","organizations_url":"https://api.github.com/users/gedare/orgs","repos_url":"https://api.github.com/users/gedare/repos","events_url":"https://api.github.com/users/gedare/events{/privacy}","received_events_url":"https://api.github.com/users/gedare/received_events","type":"User","site_admin":false},"repo":{"id":14051408,"name":"rtems","full_name":"gedare/rtems","owner":{"login":"gedare","id":1657385,"avatar_url":"https://avatars2.githubusercontent.com/u/1657385?v=4","gravatar_id":"","url":"https://api.github.com/users/gedare","html_url":"https://github.com/gedare","followers_url":"https://api.github.com/users/gedare/followers","following_url":"https://api.github.com/users/gedare/following{/other_user}","gists_url":"https://api.github.com/users/gedare/gists{/gist_id}","starred_url":"https://api.github.com/users/gedare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gedare/subscriptions","organizations_url":"https://api.github.com/users/gedare/orgs","repos_url":"https://api.github.com/users/gedare/repos","events_url":"https://api.github.com/users/gedare/events{/privacy}","received_events_url":"https://api.github.com/users/gedare/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gedare/rtems","description":"Kernel, networking, file-systems, drivers, BSPs, samples, and testsuite.","fork":true,"url":"https://api.github.com/repos/gedare/rtems","forks_url":"https://api.github.com/repos/gedare/rtems/forks","keys_url":"https://api.github.com/repos/gedare/rtems/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gedare/rtems/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gedare/rtems/teams","hooks_url":"https://api.github.com/repos/gedare/rtems/hooks","issue_events_url":"https://api.github.com/repos/gedare/rtems/issues/events{/number}","events_url":"https://api.github.com/repos/gedare/rtems/events","assignees_url":"https://api.github.com/repos/gedare/rtems/assignees{/user}","branches_url":"https://api.github.com/repos/gedare/rtems/branches{/branch}","tags_url":"https://api.github.com/repos/gedare/rtems/tags","blobs_url":"https://api.github.com/repos/gedare/rtems/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gedare/rtems/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gedare/rtems/git/refs{/sha}","trees_url":"https://api.github.com/repos/gedare/rtems/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gedare/rtems/statuses/{sha}","languages_url":"https://api.github.com/repos/gedare/rtems/languages","stargazers_url":"https://api.github.com/repos/gedare/rtems/stargazers","contributors_url":"https://api.github.com/repos/gedare/rtems/contributors","subscribers_url":"https://api.github.com/repos/gedare/rtems/subscribers","subscription_url":"https://api.github.com/repos/gedare/rtems/subscription","commits_url":"https://api.github.com/repos/gedare/rtems/commits{/sha}","git_commits_url":"https://api.github.com/repos/gedare/rtems/git/commits{/sha}","comments_url":"https://api.github.com/repos/gedare/rtems/comments{/number}","issue_comment_url":"https://api.github.com/repos/gedare/rtems/issues/comments{/number}","contents_url":"https://api.github.com/repos/gedare/rtems/contents/{+path}","compare_url":"https://api.github.com/repos/gedare/rtems/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gedare/rtems/merges","archive_url":"https://api.github.com/repos/gedare/rtems/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gedare/rtems/downloads","issues_url":"https://api.github.com/repos/gedare/rtems/issues{/number}","pulls_url":"https://api.github.com/repos/gedare/rtems/pulls{/number}","milestones_url":"https://api.github.com/repos/gedare/rtems/milestones{/number}","notifications_url":"https://api.github.com/repos/gedare/rtems/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gedare/rtems/labels{/name}","releases_url":"https://api.github.com/repos/gedare/rtems/releases{/id}","deployments_url":"https://api.github.com/repos/gedare/rtems/deployments","created_at":"2013-11-01T19:07:01Z","updated_at":"2016-01-07T19:08:15Z","pushed_at":"2018-03-14T06:54:00Z","git_url":"git://github.com/gedare/rtems.git","ssh_url":"git@github.com:gedare/rtems.git","clone_url":"https://github.com/gedare/rtems.git","svn_url":"https://github.com/gedare/rtems","homepage":"http://git.rtems.org/rtems/","size":111417,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gedare/rtems/pulls/1"},"html":{"href":"https://github.com/gedare/rtems/pull/1"},"issue":{"href":"https://api.github.com/repos/gedare/rtems/issues/1"},"comments":{"href":"https://api.github.com/repos/gedare/rtems/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/gedare/rtems/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/gedare/rtems/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gedare/rtems/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/gedare/rtems/statuses/d639bc5a7b2d9d1fdb841d8083b8ebe9a6bdc116"}},"author_association":"NONE"}}
{"actor":{"display_login":"sammanthp007"}}