[so] [SO][Tema2][Windows] Problema sincronizare fisier
Cosmin Stefan-Dobrin
cosminstefanxp at gmail.com
Sat Apr 23 17:12:40 EEST 2011
Salut,
Asa cum spune si titlul, am o mica problema cu sincronizarea datelor in
fisierul de ram (functia w_sync_mapping). Mai exact, la testul 22,
test_mapping_write_is_carried_through_to_file, in apelul w_sync_mapping,
functia FlushViewOfFile imi iese cu eroare. Mai jos sa gaseste outputul meu:
============================================================================
Z:\so\tema3\win>vmsim_test 22
[LIB][DEBUG] Page SIZE: 65536
[LIB][DEBUG] Init finished.
[LIB][DEBUG] Creating new allocation of 10 pages and 4 frames.
[LIB][DEBUG] VirtualAlloc (reserve) returned 00350000.
[LIB][DEBUG] Virtual memory mapping successful at address: '00350000'.
[LIB][DEBUG] Created '.\swp361.tmp' swap file.
[LIB][DEBUG] Created '.\ram362.tmp' ram file.
[LIB][DEBUG] Page Table and Frame Table initialization complete.
[LIB][DEBUG] Alloc complete.
[TESTER][DEBUG] exception address: 004029B0
[LIB][DEBUG] Page Fault Handler triggered at address '00352EE5'.
[LIB][DEBUG] Page 0 starting at 00350000 (Dirty 0, Prot 2, State 2) on
allocation starting at 00350000.
[LIB][DEBUG] Page not alloc'ed. Alloc'ing on frame '0'.
[LIB][DEBUG] Alloc'ing on frame 0 with previous page table association
00000000.
[LIB][DEBUG] Ret Val: 00350000; Page Start: 00350000; 0
[LIB][DEBUG] Page cleaning...
[LIB][DEBUG] Ret Val: 00350000; Page Start: 00350000; 0
[LIB][DEBUG] Page mapped on ram on frame 0.
[LIB][DEBUG] Page Handler FINISHED.
[TESTER][DEBUG] exception address: 004029B0
[LIB][DEBUG] Page Fault Handler triggered at address '00352EE5'.
[LIB][DEBUG] Page 0 starting at 00350000 (Dirty 0, Prot 0, State 0) on
allocation starting at 00350000.
[LIB][DEBUG] Page in RAM. Changing protection to RW.
[LIB][DEBUG] Old file mapping unmapped. Mapping with new rights on same
frame 0...
[LIB][DEBUG] Ret Val: 00350000; Page Start: 00350000; 0
[LIB][DEBUG] Page Handler FINISHED.
[TESTER][DEBUG] After write, in memory: 18
EroareWSync: Attempt to access invalid address.
[TESTER][DEBUG] Found 0; Should've been: 18
[TESTER][DEBUG] Found 0; Should've been: 18
[TESTER][DEBUG] Found 0; Should've been: 18
[TESTER][DEBUG] Found 0; Should've been: 18
test_mapping_write_is_carried_through_to_file...............failed [
0/100]
============================================================================
Dupa cum se observa, in ultima portiune, FlushViewOfFile imi iese cu eroarea
Attempt to access invalid address. Daca in apelul w_sync_mapping din functia
de test pun 1 (sa imi flush-uiasca __doar prima pagina__), testul trece cu
brio. Deci evident e o problema cand acel flush intra peste paginile care
sunt mapate in memorie (VirtualAlloc), dupa pagina mapata peste fisier.
Si ca o scurta descriere a ce am facut in cod, initial am mapat (ca in
exemplu), granular, fiecare pagina virtuala cu flagurile:
VirtualAlloc( addr, page_size, MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS);
si apoi, la maparea fisierului ram, realizez VirtualFree, Creez un
FileMapping cu flagurile:
CreateFileMapping( file_handle, NULL, (DWORD) PAGE_READWRITE, 0, 0,
NULL);
si mapez fisierul:
MapViewOfFileEx( mHandle, desired_access, 0,
file_page_no*page_size, page_size, address);
Am pus flagurile mai sus pentru ca probabil e o problema la alocare sau
mapare.
Thanks for your help!
Sarbatori fericite,
Cosmin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cursuri.cs.pub.ro/pipermail/so/attachments/20110423/26abf815/attachment.htm>
More information about the so
mailing list