Commit 7c2d6a781cb806fdb99837015c773398f582caf1

Authored by bellard
1 parent f1510b2c

faster task switch


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@270 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 14 additions and 4 deletions
@@ -585,22 +585,32 @@ void page_unmap(void) @@ -585,22 +585,32 @@ void page_unmap(void)
585 { 585 {
586 PageDesc *p, *pmap; 586 PageDesc *p, *pmap;
587 unsigned long addr; 587 unsigned long addr;
588 - int i, j, ret; 588 + int i, j, ret, j1;
589 589
590 for(i = 0; i < L1_SIZE; i++) { 590 for(i = 0; i < L1_SIZE; i++) {
591 pmap = l1_map[i]; 591 pmap = l1_map[i];
592 if (pmap) { 592 if (pmap) {
593 p = pmap; 593 p = pmap;
594 - for(j = 0;j < L2_SIZE; j++) { 594 + for(j = 0;j < L2_SIZE;) {
595 if (p->flags & PAGE_VALID) { 595 if (p->flags & PAGE_VALID) {
596 addr = (i << (32 - L1_BITS)) | (j << TARGET_PAGE_BITS); 596 addr = (i << (32 - L1_BITS)) | (j << TARGET_PAGE_BITS);
597 - ret = munmap((void *)addr, TARGET_PAGE_SIZE); 597 + /* we try to find a range to make less syscalls */
  598 + j1 = j;
  599 + p++;
  600 + j++;
  601 + while (j < L2_SIZE && (p->flags & PAGE_VALID)) {
  602 + p++;
  603 + j++;
  604 + }
  605 + ret = munmap((void *)addr, (j - j1) << TARGET_PAGE_BITS);
598 if (ret != 0) { 606 if (ret != 0) {
599 fprintf(stderr, "Could not unmap page 0x%08lx\n", addr); 607 fprintf(stderr, "Could not unmap page 0x%08lx\n", addr);
600 exit(1); 608 exit(1);
601 } 609 }
  610 + } else {
  611 + p++;
  612 + j++;
602 } 613 }
603 - p++;  
604 } 614 }
605 free(pmap); 615 free(pmap);
606 l1_map[i] = NULL; 616 l1_map[i] = NULL;