Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I really struggle with this question, please save me..... 4 [10 marks! Let us consider a system where every integer is unsigned and uses 10

I really struggle with this question, please save me.....image text in transcribedimage text in transcribed

4 [10 marks! Let us consider a system where every integer is unsigned and uses 10 bits. Most programming languages provide ways to manipulate the bits of integers (signed or unsigned). For instance, if r and y are two such integers, then . & is the bitwise AND operator. x & y denotes the integer whose ith bit is the ith bit of x and the ith bit of y. For instance, assuming that we have unsigned integers 74610-1011 1010102 and 46910 01110101012, then 746 & 469 00110000002 192 of x or the ith bit of y. For instance, 746 | 469-111 111 111 12 102310 bit of x xor the ith bit of y. For instance, 746 D 469 1100111111283110 | is the bitwise OR operator. r | y denotes the integer whose ith bit is the ith bit . is the bitwise XOR operator. r y denotes the integer whose ith bit is the ith >> is the bitwise right shift operator. r i denotes the integer obtained by "deleting" the rightmost i bits of r, and adding i 0 bits to the left of the remaining bits. For instance, 746 >>40000101110 (the bits 1010 were removed) We can perform several operations simply by manipulating the sequence of bits that represents an integer using these operators. In this problem, we look at some of them. a. [2 marks] There are several situations where we would like to only retain some of the bits of an integer r. For instance, the last 6 bits of 746 equal 1010102 4210 Given x, what expression would give you an integer that corresponds to the last 6 bits of r? b 12 marks! Continuing from the previous question, what expression would give an integer that corresponds to the next 3 bits of r (those corresponding to the positions 28, 27 and 26)? For instance, for 746, this would be 0112 310 c. [6 marks In the UNIX file system, there are three types of access permission: o read: determines if someone can open a file for reading, or list files in a directory o write: determines if someone can update a file, or create new files in a directory execute: determines if someone can execute a file (program) or access files (folder) (folder) inside a directory (folder) Each can be either allowed or disallowed. These permissions are stored in groups of three: there is one permission for the owner of the file or directory, one for the group the file belongs to (a group could be something like "faculty", or "ugrad-student") and finally one for everybody e For instance, the pattern 111 101 100 means, in order: o The file owner can read, write or execute the file. . Other users in the file's group can read or execute it, but not write to it. . Users other than the owner or members of the file's group can only read it. Suppose that the permissions for a file are stored as a 10-bit integer (i.e. the permis- sions shown in the previous paragraph will be stored as 01111011002 49210). To set or change permissions, the system performs bit-wise operations on the permis- sions and predefined constant values. If p is the number representing the permissions of a file, write one or more expressions that will set the permissions p in the way described in each of the following cases. If you use constants you can write them in either decimal or in binary notation: i. Allow the owner to read, write and execute the file, members of the file's group to read and execute it, but other users to only execute it. ii. Give the owner and members of the file's group write access to the file, leaving all other permissions unchanged iii. Remove write and execute per missions to the file from everyone except it s owner leaving all other permissions unchanged

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions