Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
770114c8
Commit
770114c8
authored
Jul 02, 2013
by
Pedro Gonnet
Browse files
add global timers for cell lock/unlock.
Former-commit-id: 946b62b78997ce0649f28d20afac5fd52d59137b
parent
f36bddec
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
770114c8
...
...
@@ -33,35 +33,12 @@
#include
"cycle.h"
#include
"lock.h"
#include
"task.h"
#include
"timers.h"
#include
"part.h"
#include
"cell.h"
#include
"error.h"
#include
"inline.h"
/* The timers. */
ticks
cell_timer
[
cell_timer_count
];
/* Define the timer macros. */
#ifdef TIMER_VERBOSE
#ifndef TIMER
#define TIMER
#endif
#endif
#ifdef TIMER
#define TIMER_TIC ticks tic = getticks();
#define TIMER_TOC(t) timer_toc( t , tic )
#define TIMER_TIC2 ticks tic2 = getticks();
#define TIMER_TOC2(t) timer_toc( t , tic2 )
INLINE
static
ticks
timer_toc
(
int
t
,
ticks
tic
)
{
ticks
d
=
(
getticks
()
-
tic
);
__sync_add_and_fetch
(
&
cell_timer
[
t
]
,
d
);
return
d
;
}
#else
#define TIMER_TIC
#define TIMER_TOC(t)
#endif
/**
* @brief Lock a cell and hold its parents.
...
...
@@ -76,7 +53,7 @@ int cell_locktree( struct cell *c ) {
/* First of all, try to lock this cell. */
if
(
c
->
hold
||
lock_trylock
(
&
c
->
lock
)
!=
0
)
{
TIMER_TOC
(
cell_
timer_tree
);
TIMER_TOC
(
timer_
lock
tree
);
return
1
;
}
...
...
@@ -88,7 +65,7 @@ int cell_locktree( struct cell *c ) {
error
(
"Failed to unlock cell."
);
/* Admit defeat. */
TIMER_TOC
(
cell_
timer_tree
);
TIMER_TOC
(
timer_
lock
tree
);
return
1
;
}
...
...
@@ -111,7 +88,7 @@ int cell_locktree( struct cell *c ) {
/* If we reached the top of the tree, we're done. */
if
(
finger
==
NULL
)
{
TIMER_TOC
(
cell_
timer_tree
);
TIMER_TOC
(
timer_
lock
tree
);
return
0
;
}
...
...
@@ -127,7 +104,7 @@ int cell_locktree( struct cell *c ) {
error
(
"Failed to unlock cell."
);
/* Admit defeat. */
TIMER_TOC
(
cell_
timer_tree
);
TIMER_TOC
(
timer_
lock
tree
);
return
1
;
}
...
...
@@ -154,7 +131,7 @@ void cell_unlocktree( struct cell *c ) {
for
(
finger
=
c
->
parent
;
finger
!=
NULL
;
finger
=
finger
->
parent
)
__sync_fetch_and_sub
(
&
finger
->
hold
,
1
);
TIMER_TOC
(
cell_
timer_tree
);
TIMER_TOC
(
timer_
lock
tree
);
}
...
...
src/cell.h
View file @
770114c8
...
...
@@ -21,15 +21,6 @@
#define cell_sid_dt 13
/* The queue timers. */
enum
{
cell_timer_none
=
0
,
cell_timer_tree
,
cell_timer_count
,
};
extern
ticks
cell_timer
[
cell_timer_count
];
/* Structure to store the data of a single cell. */
struct
cell
{
...
...
src/timers.h
View file @
770114c8
...
...
@@ -36,7 +36,7 @@ enum {
timer_doghost
,
timer_gettask
,
timer_qlock
,
timer_
stalled
,
timer_
locktree
,
timer_runners
,
timer_step
,
timer_count
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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