What is the operator << in the context of virtual memory paging?

Asked

Viewed 106 times

0

I’m seeing the implementation of virtual memory and I have this code:

#define INDEX_FROM_BIT(a) (a / 8*4)
#define OFFSET_FROM_BIT(a)(a % (8*4))



static void set_frame(u32int frame_addr)
{

    u32int frame = frame_addr/0x1000;

    u32int idx = INDEX_FROM_BIT(frame);

    u32int off = OFFSET_FROM_BIT(frame);

    frames[idx] |=(0x1 << off);
}

static void clear_frame(u32int frame_addr)
{
    u32int frame = frame_addr/0x1000;

    u32int idx = INDEX_FROM_BIT(frame);

    u32int off = OFFSET_FROM_BIT(frame);

    frames[idx] &= ~(0x1 << off);

}

Because that (0x01 << off) and so used as its context for virtual memory?

  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

1 answer

4

This is the bit displacement operator. It’s faster than exponentiating when the base is 2.

The use in virtual memory is broad, depends on each context.

Obviously the access to physical memory is always done through calculations in relation to the original virtual address. You also need to mark where each page is. Anyway, it depends on the implementation but the field of computation as a whole benefits from direct bit manipulation operations because our area works naturally with numbers and sets based on 2.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.