This file checks the lock traces generated by checklock.c. More...
#include "config.h"
#include "util/log.h"
#include "util/rbtree.h"
#include "util/locks.h"
#include "util/fptr_wlist.h"
Data Structures | |
struct | order_id |
keep track of lock id in lock-verify application More... | |
struct | order_lock |
a lock More... | |
struct | lock_ref |
reference to a lock in a rbtree set More... | |
Macros | |
#define | STRMAX 1024 |
max length of strings: filenames and function names. | |
Functions | |
static void | usage (void) |
print program usage help | |
static int | read_header (FILE *in) |
read header entry. More... | |
static int | readup_str (char **str, FILE *in) |
read a string from file, false on error | |
static void | read_create (rbtree_type *all, FILE *in) |
read creation entry | |
static struct order_lock * | insert_lock (rbtree_type *all, struct order_id *id) |
insert lock entry (empty) into list | |
static void | read_lock (rbtree_type *all, FILE *in, int val) |
read lock entry | |
static void | readinput (rbtree_type *all, char *file) |
read input file | |
static void | found_cycle (struct lock_ref *visit, int level) |
print cycle message | |
static int | detect_cycle (struct lock_ref *visit, struct lock_ref *from) |
Detect cycle by comparing visited now with all (unvisited) bigger nodes. | |
static void | search_cycle (struct lock_ref *visit, int level, struct lock_ref *from) |
recursive function to depth first search for cycles. More... | |
static void | check_order_lock (struct order_lock *lock) |
Check ordering of one lock. | |
static void | check_order (rbtree_type *all_locks) |
Check ordering of locks. | |
static void | dellockref (rbnode_type *node, void *ATTR_UNUSED(arg)) |
delete lock ref | |
static void | delnode (rbnode_type *node, void *ATTR_UNUSED(arg)) |
delete lock node | |
static void | locks_free (rbtree_type *all_locks) |
delete allocated memory | |
int | main (int argc, char *argv[]) |
main program to verify all traces passed | |
Variables | |
static int | errors_detected = 0 |
count of errors detected | |
static int | verb = 0 |
verbose? | |
This file checks the lock traces generated by checklock.c.
Checks if locks are consistently locked in the same order. If not, this can lead to deadlock if threads execute the different ordering at the same time.
|
static |
read header entry.
in | file to read header of. |
Referenced by readinput().
recursive function to depth first search for cycles.
visit | the lock visited at this step. its dfs_next pointer gives the visited lock up in recursion. same as lookfor at level 0. |
level | depth of recursion. 0 is start. |
from | search for matches from unvisited node upwards. |
References detect_cycle(), and found_cycle().
Referenced by check_order_lock().