程序代写 15-213/18-243 Fall 2009

15-213/18-243 Fall 2009

2. a and d

Copyright By PowCoder代写 加微信 powcoder

VA_GET_PPO: (virtual & 0xfff)
VA_GET_PTI: ((virtual >> 12) & 0x3ff)
VA_GET_PDI: ((virtual >> 22) & 0x3ff)
PDE_GET_PTBA: (pde & 0xfffff000)
PTE_GET_PBA: (pde & 0xfffff000)
IS_PRESENT: (pte & 0x1)
IS_WRITABLE: ((pte & 0x2) >> 1)
SET_PRESENT: (((pte >> 1) << 1) + pres) SET_WRITABLE: ((pte & 0x1) + ((pte >> 2) << 2) + (write << 1)) A. pushes return address onto stack B. moves the stack frame up to previous function (mov %ebp, %esp; pop %ebp) C. pops return address off stack D. pushed onto stack in reverse order (e.g., push arg3, push arg2, push arg1) E. in the %eax register +-------------------------------------+ | callee stack frame | +-------------------------------------+ | 0xbeefbabe | Stack Growing Down! | +-------------------------------------+ V | 0x5 | +-------------------------------------+ | 0xcafebeef | +-------------------------------------+ | return address | +-------------------------------------+ | old ebp | +-------------------------------------+ | printf stack frame | G. value of fd might change before the new thread accesses it, because it is on the creating thread's stack. B. 0, 5, 10, 15 A. If any of the mallocs fail, other than the first one, memory allocated in the function will be leaked. struct cache_entry *entry = malloc(sizeof(struct cache_entry)); if (!entry) goto L1; /* (or "return NULL") */ entry->url = malloc(url_length+1);
if (!entry->url)
entry->browser_signature = malloc(signature_length+1);
if (!entry->browser_signature)
entry->http_referrer = malloc(referrer_length+1);
if (!entry->http_referrer)
entry->content = malloc(content_length+1);
if (!entry->content)
return entry;
free(entry->http_referrer);
free(entry->browser_signature);
free(entry->url);
free(entry);
return NULL;

Server | Client
———————
socket |
bind |
listen |
accept |
read |

B. recv (like read) is not guaranteed to read a full 4096 bytes (i.e., it
can return less as a “short read”). It needs to be placed in a loop.

lower 32 bits
to the nearest even

F. condvar

**********
Problem 10
**********

A. id_from = id_to
B. Deadlock is possible with any concurrent circular transfers
(e.g., transfer_dollar(A, B) and transfer_dollar(B, A))

**********
Problem 11
**********

**********
Problem 12
**********

A. There is no check for an overflow! The if(a+b <0) statement does not appear in the assembly code. Nor does the printf or a jump out of the B. Newer versions of gcc take advantage of the "total license" policy within the C standard, which states that any undefined behavior can be assumed to never occur, and optimizations can be made off of this fact. Signed integer overflow in the C language is undefined, and therefore newer versions of gcc believe that it cannot occur and will make optimizations with that in mind. Because integer overflow "can never occur", the compiler has kindly removed the if statement. C. After the call to printf, insert the following lines of assembly: cmp $0,%ebx jle 8048397
push &”Overflow!, stopping\n”
jmp

**********
Problem 13
**********

A. Dannenberg
C. 4 (SS, BB, TT, GG)
E. my artistic skills cannot be properly conveyed in text, but ancient
artists are blushing.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com