Subversion Repositories HelenOS

Rev

Rev 2131 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2131 Rev 2307
Line 71... Line 71...
71
 * possible occurence of deadlock.
71
 * possible occurence of deadlock.
72
 *
72
 *
73
 * @param sl Pointer to spinlock_t structure.
73
 * @param sl Pointer to spinlock_t structure.
74
 */
74
 */
75
#ifdef CONFIG_DEBUG_SPINLOCK
75
#ifdef CONFIG_DEBUG_SPINLOCK
76
#define DEADLOCK_THRESHOLD  100000000
-
 
77
void spinlock_lock_debug(spinlock_t *sl)
76
void spinlock_lock_debug(spinlock_t *sl)
78
{
77
{
79
    count_t i = 0;
78
    count_t i = 0;
80
    char *symbol;
79
    char *symbol;
81
    bool deadlock_reported = false;
80
    bool deadlock_reported = false;
82
 
81
 
83
    preemption_disable();
82
    preemption_disable();
84
    while (test_and_set(&sl->val)) {
83
    while (test_and_set(&sl->val)) {
85
 
84
 
86
        /*
85
        /*
87
         * We need to be careful about printflock and fb_lock.
86
         * We need to be careful about printf_lock and fb_lock.
88
         * Both of them are used to report deadlocks via
87
         * Both of them are used to report deadlocks via
89
         * printf() and fb_putchar().
88
         * printf() and fb_putchar().
90
         *
89
         *
91
         * We trust our code that there is no possible deadlock
90
         * We trust our code that there is no possible deadlock
92
         * caused by these two locks (except when an exception
91
         * caused by these two locks (except when an exception
93
         * is triggered for instance by printf() or fb_putchar()).
92
         * is triggered for instance by printf() or fb_putchar()).
94
         * However, we encountered false positives caused by very
93
         * However, we encountered false positives caused by very
95
         * slow VESA framebuffer interaction (especially when
94
         * slow VESA framebuffer interaction (especially when
96
         * run in a simulator) that caused problems with both
95
         * run in a simulator) that caused problems with both
97
         * printflock and fb_lock.
96
         * printf_lock and fb_lock.
98
         *
97
         *
99
         * Possible deadlocks on both printflock and fb_lock
98
         * Possible deadlocks on both printf_lock and fb_lock
100
         * are therefore not reported as they would cause an
99
         * are therefore not reported as they would cause an
101
         * infinite recursion.
100
         * infinite recursion.
102
         */
101
         */
103
        if (sl == &printflock)
102
        if (sl == &printf_lock)
104
            continue;
103
            continue;
105
#ifdef CONFIG_FB
104
#ifdef CONFIG_FB
106
        if (sl == &fb_lock)
105
        if (sl == &fb_lock)
107
            continue;
106
            continue;
108
#endif
107
#endif