You are on page 1of 1

 Home  Dashboard  Events  My courses  This course   1  Hide

Felician-Nicu
blocks Herman
Standard view

Operating System Design, Fall 2021 

  My courses  OSD (2021/2022 - A. Coleșa)  29 November - 5 December  Lab activity guidance

Lab activity guidance  Navigation


Preparations:   Dashboard

We will not be running tests today and we simply want to boot HAL9000, before starting work make sure you run the RemoveAllTests project.
 Site home
Then after each time you build HAL9000, start manually the VM from VMWare workstation.  Site pages
You should use the HAL9000.sln VS solution now (instead of HAL9000_WithoutApplications.sln). You should also change the con guration to "Virtual Memory" instead of "Threads" or "Userprog".
 My courses
NOTE: Before starting the problems you should already have the rst 7 points implemented from laboratory 6.
 PRC/CND (2021/2022 - E. Cebuc)
Swapping:  RC/CN (2020/2021 - B. Iancu, V. Dădârlat)
LEARNING  CAN / ADC (2019/2020 - B. Iancu)

1. Have a look at the following ash animations:  SO.2020.Seria2


       -> Virtual memory (https://www.uttyler.edu/ les/cosc3355/animations/virtualmemory.swf)
 OSD (2021/2022 - A. Coleșa)
       -> Demand paging (https://www.uttyler.edu/ les/cosc3355/animations/demandpaging.swf)
       -> Solving a page fault (https://www.uttyler.edu/ les/cosc3355/animations/pagefaultsteps.swf)  Participants
  To view the animations, navigate to https://ru e.rs/demo/, then click on "Local SWF" and paste the address of the SWF le in "File name" box.
  In case you don't want to view ash animations, you might check out this article: click_here          Badges
 Competencies
   2. See how the swapping area is detected and con gured during the boot process in _IomuInitializeSwapFile().
    Grades
      In order to get access to the swapping area, or swap le, IomuGetSwapFile() can be used. It returns a pointer to a FILE_OBJECT.
        General
      Now that we have access to the swap le we may read and write to it using IoReadFile() and IoWriteFile(). The only constraints are that the size read/written must be the size of a page and the  27 September - 3 October
o set must also be page-aligned.
    4 October - 10 October
   3. Determine the size of the swap partition:
  
 11 October - 17 October
       -> To determine the size of the swap partition, add the following lines in _IomuInitializeSwapFile():  18 October - 24 October 

PARTITION_INFORMATION partitionInformation;  25 October - 31 October


PIRP pIrp = IoBuildDeviceIoControlRequest(IOCTL_VOLUME_PARTITION_INFO,
 1 November - 7 November
pVpb->VolumeDevice,
NULL,  8 November - 14 November
0,
&partitionInformation,  15 November - 21 November
sizeof(PARTITION_INFORMATION));  22 November - 28 November
if (NULL == pIrp)
{  29 November - 5 December
LOG_ERROR("IoBuildDeviceIoControlRequest failed\n");
continue; Lab 10 git di
} Lab activity guidance

status = IoCallDriver(pVpb->VolumeDevice, pIrp); Send IMPLEMENTATION document for the


if (!SUCCEEDED(status)) "Userprog" mo...
{
LOG_FUNC_ERROR("IoCallDriver", status);  6 December - 12 December
continue;
}  13 December - 19 December
 20 December - 26 December
if (!SUCCEEDED(pIrp->IoStatus.Status))
{  27 December - 2 January
LOG_FUNC_ERROR("IoCallDriver", pIrp->IoStatus.Status);
 3 January - 9 January
continue;
}  10 January - 16 January

LOG("swap size is %U bytes!\n", partitionInformation.PartitionSize * SECTOR_SIZE);  Examinations


       
 PSO (2021/2022 - A. Coleșa)
       Store this size in the IOMU_DATA structure, we'll name it SwapFileSize.
Problems     LFT (2020/2021, A. Marginean, seria 2)
  
   0. Before you start this laboratory you must have the implementation of all the problems from the last laboratory.  SI (2020/2021, R. R. Slavescu)
    Consiliere Studenti 2021-2022
   1. Implementing the swapping mechanism:
    PF seria B (2020/2021 - R.R. Slavescu)
       -> Allocate a Bitmap to maintain the list of used swap slots
More...
  
           Add two new elds IOMU_DATA below SwapFile: BITMAP SwapBitmap and PVOID SwapBitmapData;
           Initialize the bitmap in the following way (NOTE: recommended place to do it: IomuLateInit):
       
DWORD bitmapSize = BitmapPreinit(&m_iomuData.SwapBitmap, m_iomuData.SwapFileSize / PAGE_SIZE);

m_iomuData.SwapBitmapData = ExAllocatePoolWithTag(PoolAllocatePanicIfFail, bitmapSize, HEAP_IOMU_TAG, 0);

BitmapInit(&m_iomuData.SwapBitmap, m_iomuData.SwapBitmapData);
           
       -> Initialize a lock to protect to the bitmap.
       -> Implement two functions in iomu.h:
       
// Reserves a swap slot from the swap bitmap and writes the contents of VirtualAddress to the reserved slot in the swap file.
STATUS
IomuSwapOut(
IN PVOID VirtualAddress
);

// Retrieves the contents of VirtualAddress from the swap file and releases the appropriate swap slot reservation.
STATUS
IomuSwapIn(
OUT PVOID VirtualAddress
);
  
           HINTS:
               Have a look at PmmReserveMemoryEx() and PmmReleaseMemory() to see examples of how to work with a bitmap
               Maintain a per-process list of virtual addresses to swap slots mappings to be able to determine which swap slot you need to read back in IomuSwapIn().
      
       -> Modify VmmSolvePageFault() to treat the case in which the page causing the #PF is located in the swap area. NOTE: as a hackish implementation you could directly call IomuSwapIn() and if you
don't have the reservation you could return a non success status from the function.
   2. Add a new system call: SwapOut which receives as a parameter the virtual address which to swap out on disk. Add a new user mode application or modify an existing one and issue this system
call in the following ways:
  
{
char b;
PBYTE pAddress;

SyscallVirtualAlloc(NULL, 8 * PAGE_SIZE, VMM_ALLOC_TYPE_COMMIT | VMM_ALLOC_TYPE_RESERVE, PAGE_RIGHTS_READWRITE, UM_INVALID_HANDLE_VALUE, 0,


&pAddress);

memset(pAddress, 0x91, 8 * PAGE_SIZE);

SwapOut(pAddress);

for (DWORD i = 0; i < 8 * PAGE_SIZE; ++i)


{
LOG("Value at offset %u is 0x%x\n", i, pAddress[i]);
}

// swap out the stack


SwapOut(&b);

// Lets have some fun


SwapOut(NULL);
}
Last modi ed: Friday, 26 November 2021, 8:14 AM

PREVIOUS ACTIVITY NEXT ACTIVITY


 Send IMPLEMENTATION document for the "Userprog" module (only students attending 
Lab 10 git di
project classes in EVEN WEEKS)

Jump to...

Get the mobile app

You might also like