//************************************************************************
// define page table entry struct
//************************************************************************
struct PTE
{
struct PTE_INFO
{
unsigned int
PROG_FILE:1, // if turned on indicates that page should
// be taken from the program file (executable)
SWAP_FILE:1, // if turned on indicates that page
// is swapped out to the swap file
// NOTE: 2 bits PROF_FILE/SWAP file are used
// because both bits turned off indicate BSS page
VALID:1, // indicates page presence/absence in the memory
DIRTY:1, // indicates whether the page was modified
RDONLY:1, // indicates existence/absence of write rmission
// for the page
EMPTY:3; // reserved bits (not in use)
} pte_info;
// page tabe entry data (union is used for alignment to 8 bits)
union {
struct PTE_INFO info;
char value; // just to initiate easily info bits
} PTE_DATA;
// number of frame in physical memory
short PTE_PHYS_PAGE; // even thought sizeof (short) > 512
};
Вот достался такой код, как правильно заюзать такую структуру ?
т.е. нужен доступ к полям PROG_FILE, SWAP_FILE, VALID, DIRTY, RDONLY.
Мой код :
int main(int argc, char** argv)
{
GList* VMemInfo;
int i;
for( i =0; i <10; i++) { VMemInfo =g_list_append (VMemInfo, NULL); VMemInfo[i].data =malloc(sizeof(struct PTE)); }/* end for */ /* здесь я хочу проинициализировать PROG_FILE, SWAP_FILE, VALID, DIRTY, RDONLY */ .
. . . .
return 0;
} /* end main */ Вопрос больще по Си, я пока учусь. Сильно не пинайте. Спасибо.