Subversion Repositories Kolibri OS

Rev

Rev 2455 | Rev 5363 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2455 Rev 3126
Line 48... Line 48...
48
 
48
 
49
run_test2:
49
run_test2:
Line 50... Line 50...
50
        ret
50
        ret
51
 
51
 
52
run_test3:
52
run_test3:
53
; 1024000 times run random operation.
53
; 1024 times run random operation.
54
; Randomly select malloc(random size from 1 to 1023)
54
; Randomly select malloc(random size from 1 to 1023)
55
; or free(random of previously allocated areas)
55
; or free(random of previously allocated areas)
56
        mov     edi, 0x12345678
56
        mov     edi, 0x12345678
57
        xor     esi, esi        ; 0 areas allocated
57
        xor     esi, esi        ; 0 areas allocated
58
        mov     ebx, 1024000
58
        mov     ebx, 1024
59
.loop:
59
.loop:
60
        imul    edi, 1103515245
60
        imul    edi, 1103515245
61
        add     edi, 12345
61
        add     edi, 12345
Line 76... Line 76...
76
        jz      .loop
76
        jz      .loop
77
        push    ebx
77
        push    ebx
78
        push    eax
78
        push    eax
79
;       mov     ecx, [saved_state_num]
79
;       mov     ecx, [saved_state_num]
80
;       mov     [saved_state+ecx*8], eax
80
;       mov     [saved_state+ecx*8], eax
-
 
81
        push    edi
81
        call    malloc_with_test
82
        call    malloc_with_test
-
 
83
        pop     ecx
-
 
84
        cmp     ecx, edi
-
 
85
        jnz     edi_destroyed
82
;       mov     ecx, [saved_state_num]
86
;       mov     ecx, [saved_state_num]
83
;       mov     [saved_state+ecx*8+4], eax
87
;       mov     [saved_state+ecx*8+4], eax
84
;       inc     [saved_state_num]
88
;       inc     [saved_state_num]
85
        pop     ecx
89
        pop     ecx
86
        pop     ebx
90
        pop     ebx
Line 111... Line 115...
111
        mov     al, [edi]
115
        mov     al, [edi]
112
        repz scasb
116
        repz scasb
113
        jnz     memory_destroyed
117
        jnz     memory_destroyed
114
        pop     eax edi
118
        pop     eax edi
115
        push    ebx edx
119
        push    ebx edx
-
 
120
        push    edi
116
        call    free
121
        call    free
-
 
122
        pop     ecx
-
 
123
        cmp     ecx, edi
-
 
124
        jnz     edi_destroyed
117
        pop     edx ebx
125
        pop     edx ebx
118
        dec     esi
126
        dec     esi
119
        pop     eax ecx
127
        pop     eax ecx
120
        push    edi
128
        push    edi
121
        lea     edi, [esp+4]
129
        lea     edi, [esp+4]
Line 148... Line 156...
148
        call    check_mutex
156
        call    check_mutex
149
        call    check_range
157
        call    check_range
150
        ret
158
        ret
Line 151... Line 159...
151
 
159
 
-
 
160
; Stubs for kernel procedures used by heap code
-
 
161
mutex_init:
-
 
162
        and     dword [ecx], 0
152
; Stubs for kernel procedures used by heap code
163
        ret
153
wait_mutex:
164
mutex_lock:
-
 
165
        inc     dword [ecx]
-
 
166
        ret
-
 
167
mutex_unlock:
154
        inc     dword [ebx]
168
        dec     dword [ecx]
Line 155... Line 169...
155
        ret
169
        ret
156
 
170
 
157
kernel_alloc:
171
kernel_alloc:
Line 172... Line 186...
172
generic_malloc_fail:
186
generic_malloc_fail:
173
        mov     eax, 2
187
        mov     eax, 2
174
        jmp     error_with_code
188
        jmp     error_with_code
Line 175... Line 189...
175
 
189
 
176
check_mutex:
190
check_mutex:
177
        cmp     [mst.mutex], 0
191
        cmp     dword [mst.mutex], 0
178
        jnz     @f
192
        jnz     @f
179
        ret
193
        ret
180
@@:
194
@@:
181
        mov     eax, 3
195
        mov     eax, 3
Line 193... Line 207...
193
 
207
 
194
memory_destroyed:
208
memory_destroyed:
195
        mov     eax, 5
209
        mov     eax, 5
Line -... Line 210...
-
 
210
        jmp     error_with_code
-
 
211
 
-
 
212
edi_destroyed:
-
 
213
        mov     eax, 6
196
        jmp     error_with_code
214
        jmp     error_with_code
197
 
215
 
198
error_with_code:
216
error_with_code:
199
        mov     edx, saved_state_num
217
        mov     edx, saved_state_num
200
; eax = error code
218
; eax = error code
Line 206... Line 224...
206
        int3    ; simplest way to report error
224
        int3    ; simplest way to report error
207
        jmp     $-1     ; just in case
225
        jmp     $-1     ; just in case
Line 208... Line 226...
208
 
226
 
209
; Include main heap code
227
; Include main heap code
-
 
228
include '../proc32.inc'
210
include '../proc32.inc'
229
include '../struct.inc'
211
include '../const.inc'
230
include '../const.inc'
Line 212... Line 231...
212
include 'malloc.inc'
231
include 'malloc.inc'