Subversion Repositories HelenOS-historic

Rev

Rev 552 | Rev 581 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 552 Rev 557
Line 60... Line 60...
60
 *
60
 *
61
 * @param sl Pointer to spinlock_t structure.
61
 * @param sl Pointer to spinlock_t structure.
62
 */
62
 */
63
void spinlock_lock(spinlock_t *sl)
63
void spinlock_lock(spinlock_t *sl)
64
{
64
{
65
    int i = 0;
65
    count_t i = 0;
66
    __address caller = ((__address *) &sl)[-1];
66
    __address caller = ((__address *) &sl)[-1];
67
    char *symbol;
67
    char *symbol;
-
 
68
    bool deadlock_reported = false;
68
 
69
 
69
    preemption_disable();
70
    preemption_disable();
70
    while (test_and_set(&sl->val)) {
71
    while (test_and_set(&sl->val)) {
71
        if (i++ > 300000) {
72
        if (i++ > 300000) {
72
            printf("cpu%d: looping on spinlock %p:%s, caller=%p",
73
            printf("cpu%d: looping on spinlock %p:%s, caller=%p",
Line 74... Line 75...
74
            symbol = get_symtab_entry(caller);
75
            symbol = get_symtab_entry(caller);
75
            if (symbol)
76
            if (symbol)
76
                printf("(%s)", symbol);
77
                printf("(%s)", symbol);
77
            printf("\n");
78
            printf("\n");
78
            i = 0;
79
            i = 0;
-
 
80
            deadlock_reported = true;
79
        }
81
        }
80
    }
82
    }
81
 
83
 
-
 
84
    if (deadlock_reported)
-
 
85
        printf("cpu%d: not deadlocked\n", CPU->id);
-
 
86
 
82
    /*
87
    /*
83
     * Prevent critical section code from bleeding out this way up.
88
     * Prevent critical section code from bleeding out this way up.
84
     */
89
     */
85
    CS_ENTER_BARRIER();
90
    CS_ENTER_BARRIER();
86
 
91