Computer Science > STUDY GUIDE > Purdue UniversityCS 252HW1-Spring2020 (All)

Purdue UniversityCS 252HW1-Spring2020

Document Content and Description Below

CS252 Homework 1 Answer this practice exam and turn it in pdf format using the following command in data: turnin -c cs252 -p hw1 hw1.pdf Part 1. True False Questions Answer True/False (T/F) __T__... The loader is also called “Runtime Linker” __T__ COFF is a format for executable files __F__ The command "chmod 440 file" makes a file readable and writable by user, group, and others. (Makes RW by user and group) __F__ strace is a UNIX command that shows the tree of processes in the system. (Prints system calls that a program calls) __F__ All processes have a parent process. (Except the first process) Part 2. Short questions. 2. Enumerate and describe the memory sections of a program. 1) Text – Stores the instructions that the program runs. 2) Data – Stores the initialized global variables. 3) Bss – Stores the uninitialized global variables. They are initialized to zeroes. 4) Heap – Memory returned when calling malloc/new. It grows upwards. 5) Stack – It stores local variables and return addresses. It grows downwards. 3. Enumerate and describe the contents of an inode 1. Flag/ModeIt cointains the permissions for Read, Write, Execute (for Owner/Group/All) RWX. Also, tells if file is directory, device or a symbolic link. 2. Owners It contains the Userid, Groupid of the file owners. 3. Time Stamps It has the Creation time, Access Time and Modification Time of the file. 4. Size It stores the size of file in bytes. 5. Ref. Count – It contains the reference count with the number of times the i-node appears in a directory (hard links). 6. Block Index -Direct block – Points directly to the block. There are 12 of them in the structure -Single indirect – Points to a block table that has 256 entry's. There are 3 of them. -Double indirect – Points to a page table of 256 entries which then points to another page table of 256 4. Enumerate the 5 Memory Allocation Errors and describe them. 1) Memory Leaks: When we allocate a chunk of memory in heap but don’t free it. 2) Premature Free: When we free a chunk of memory and then try to access that chunk of memory which causes a SEGV. 3) Double Free: When we free a chunk of memory and then try to free that chunk of memory again which causes a SEGV. 4) Wild Free: When we try to free a chunk of memory that isn’t in the heap which causes a SEGV. 5) Memory Smashing: When we allocate an amount of memory and try to initialize it with a larger amount of data than it is supposed to hold which causes memory corruption and SEGV. 5. List and explain the attributes of an Open File Object. An Open file object contains the state of an open file. 1) I-Node: Identifies the files in a computer. Major number: Determines the devices Minor number: Determines what file it refers to inside the device. 2) Open Mode: Stores the mode with which file was opened.3) Offset: The offset used to start reading or writing from or to a file. 4) Reference Count: The number of file descriptors pointing to this file which is initially one. Increases every time file is added to a directory. The file the i-node represents will be removed when the reference count reaches 0. Malloc Below is a diagram showing current state of a memory allocator like the one implemented in lab 1. The only difference is that the arena size is only 128 bytes, to simplify the arithmetic. All of the data structures are the same as they were in the lab and the code is being run on a 64-bit linux system, like the lab machines or data. The top diagram shows how the blocks are laid out in memory, the lower diagram is a representation of the free list, and the table contains the metadata about each block. Addresses are truncated and given in decimal for simplicity. In the diagram given below there are two blocks in a single arena. Block 1 is not allocated and is the only node in the free list. Block 2 has been allocated. There is space for a second arena to be allocated if necessary. If the second arena is not required simply cross it out as in the diagram below. For each malloc/free call update the memory space diagram, free list, and table as necessary to contain the state of the allocator after performing the requested operation. For calls to malloc include the value returned by the malloc call. Example Diagram: Block Offset Size Left Size Allocated 1 ...0000 88 16 0 2 ...0088 40 88 1 ... ... ... Du mm y DummDuymmy Dummy Sent inel 1 1 2 128 BytesQuestion 1 This is the heap before the operation: Block Offset Size Left Size Allocated 1 ...0000 64 16 0 2 ...0064 64 64 1 ... ... malloc(8); Draw the heap after the operation above and fill up the table. Block Offset Size Left Size Allocated 1 ...0000 32 16 0 3 ...0032 32 32 1 2 ...0064 64 32 1 ... What is the value returned by the operation above assuming the beginning of the allocable memory in the first arena is address 10000? Returns 10032+16=10048 ... Du mm y DummDuymmy Dummy Sen tinel 1 1 2 ... Du mm y DummDuymmy Dummy Sen tinelQuestion 2 This is the heap before the operation: Block Offset Size Left Size Allocated 1 ...0000 64 16 0 2 ...0064 64 64 1 ... ... malloc(1); Draw the heap after the operation above and fill up the table. Block Offset Size Left Size Allocated 1 ...0000 32 16 0 3 ...0032 32 32 1 2 ...0064 64 32 1 ... What is the value returned by the operation above assuming the beginning of the allocable memory in the first arena is address 10000? Returns 10032+16=10048 ... Du mm y DummDuymmy Dummy Sen tinel 1 1 2 ... Du mm y DummDuymmy Dummy Sen tinelQuestion 3 This is the heap before the operation: Block Offset Size Left Size Allocated 1 ...0000 64 16 0 2 ...0064 64 64 1 ... ... malloc(32); Draw the heap after the operation above and fill up the table. Block Offset Size Left Size Allocated 1 ...0000 64 16 1 2 ...0064 64 64 1 ... ... What is the value returned by the operation above assuming the beginning of the allocable memory in the first arena is address 10000? Returns 10000+16=10016 ... Du mm y DummDuymmy Dummy Sen tinel 1 1 2 ... Du mm y DummDuymmy Dummy Sen tinelQuestion 4 This is the heap before the operation: Block Offset Size Left Size Allocated 1 ...0000 64 16 0 2 ...0064 64 64 1 ... ... malloc(128); Draw the heap after the operation above and fill up the table. Block Offset Size Left Size Allocated 1 ...0000 64 16 0 2 ...0064 64 64 1 ... ... What is the value returned by the operation above assuming the beginning of the allocable memory in the first arena is address 10000? (Assume max heap size is 128bytes). Returns NULL because 128+16=144 which is bigger than the ARENA SIZE (128). [Show More]

Last updated: 2 years ago

Preview 1 out of 26 pages

Buy Now

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

We Accept

Reviews( 0 )

$11.00

Buy Now

We Accept:

We Accept

Instant download

Can't find what you want? Try our AI powered Search

40
0

Document information


Connected school, study & course


About the document


Uploaded On

Jul 19, 2021

Number of pages

26

Written in

Seller


seller-icon
Cheryshev

Member since 4 years

102 Documents Sold

Reviews Received
6
4
1
0
1
Additional information

This document has been written for:

Uploaded

Jul 19, 2021

Downloads

 0

Views

 40

Document Keyword Tags

Recommended For You

Get more on STUDY GUIDE »

$11.00
What is Scholarfriends

In Scholarfriends, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·