Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xanadu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
SYNERG
xanadu
Commits
3318bde5
Commit
3318bde5
authored
Mar 05, 2020
by
Naman Dixit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a thread manager to grunt for dumping instrumentatio data
parent
5a17b288
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
resource_system/src/grunt/thread_manager.c
resource_system/src/grunt/thread_manager.c
+11
-7
No files found.
resource_system/src/grunt/thread_manager.c
View file @
3318bde5
...
...
@@ -5,7 +5,8 @@
typedef
struct
Thread
{
pthread_t
thread
;
Char
*
id
;
Char
*
entity_id
;
Char
*
resource_id
;
}
Thread
;
typedef
struct
Thread_Tracker
{
...
...
@@ -33,7 +34,7 @@ void threadTrackBegin (Thread_Tracker *t, Thread th)
insertion_index
=
sbufElemin
(
t
->
threads
)
-
1
;
}
htInsert
(
&
t
->
map
,
hashString
(
th
.
id
),
insertion_index
);
htInsert
(
&
t
->
map
,
hashString
(
th
.
resource_
id
),
insertion_index
);
}
internal_function
...
...
@@ -41,7 +42,8 @@ void threadTrackEnd (Thread_Tracker *t, Char *thread_id)
{
Size
index
=
htLookup
(
&
t
->
map
,
hashString
(
thread_id
));
sbufAdd
(
t
->
free_list
,
index
);
free
(
t
->
threads
[
index
].
id
);
free
(
t
->
threads
[
index
].
resource_id
);
free
(
t
->
threads
[
index
].
entity_id
);
t
->
threads
[
index
]
=
(
Thread
){
0
};
htRemove
(
&
t
->
map
,
index
);
}
...
...
@@ -61,16 +63,18 @@ void* tmProcessLoop (void *arg)
switch
(
command
.
kind
)
{
case
Thread_Manager_Command_DOCKER_CREATE
:
{
pthread_t
thread
;
pthread_create
(
&
thread
,
NULL
,
&
dockerProcessLoop
,
NULL
);
threadTrackBegin
(
&
tt
,
(
Thread
){.
id
=
command
.
id
,
.
thread
=
thread
});
pthread_create
(
&
thread
,
NULL
,
&
dockerProcessLoop
,
command
.
entity_id
);
threadTrackBegin
(
&
tt
,
(
Thread
){.
entity_id
=
command
.
entity_id
,
.
resource_id
=
command
.
resource_id
,
.
thread
=
thread
});
}
break
;
case
Thread_Manager_Command_DOCKER_DESTROY
:
{
Size
index
=
htLookup
(
&
tt
.
map
,
hashString
(
command
.
id
));
Size
index
=
htLookup
(
&
tt
.
map
,
hashString
(
command
.
resource_
id
));
pthread_t
thread
=
tt
.
threads
[
index
].
thread
;
pthread_cancel
(
thread
);
pthread_join
(
thread
,
NULL
);
threadTrackEnd
(
&
tt
,
command
.
id
);
threadTrackEnd
(
&
tt
,
command
.
resource_
id
);
}
break
;
case
Thread_Manager_Command_NONE
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment