Access control matrix in Operating Systems - Time & Space Complexity
We want to understand how the time to check permissions grows as the number of users and resources increases in an access control matrix.
How does the system's work change when more users or resources are added?
Analyze the time complexity of the following access check operation.
// Access Control Matrix check
function checkAccess(user, resource, operation) {
if (matrix[user] && matrix[user][resource]) {
return matrix[user][resource].includes(operation);
}
return false;
}
This code checks if a user has permission to perform an operation on a resource by looking up the matrix.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Checking if the operation exists in the list of permissions for the user-resource pair.
- How many times: The includes() method scans the list of permissions, which depends on the number of operations allowed for that resource.
As the number of users and resources grows, the lookup remains direct, but the time to check permissions depends on how many operations are listed.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 operations | 10 checks in the permission list |
| 100 operations | 100 checks in the permission list |
| 1000 operations | 1000 checks in the permission list |
Pattern observation: The time grows linearly with the number of operations allowed per resource for a user.
Time Complexity: O(k)
This means the time to check access grows linearly with the number of permissions listed for that user-resource pair.
[X] Wrong: "Checking access takes constant time no matter how many permissions exist."
[OK] Correct: Because the code scans the list of permissions, more permissions mean more checks, so time grows with the list size.
Understanding how permission checks scale helps you design systems that stay fast even as users and resources grow.
"What if the permissions were stored in a hash set instead of a list? How would the time complexity change?"
Practice
access control matrix primarily represent in operating systems?Solution
Step 1: Understand the purpose of access control matrix
An access control matrix is a table that shows permissions users have on resources.Step 2: Match the description to the options
Only Which users have what permissions on which resources correctly describes permissions of users on resources.Final Answer:
Which users have what permissions on which resources -> Option AQuick Check:
Access control matrix = user permissions on resources [OK]
- Confusing access control matrix with process scheduling
- Thinking it shows memory or software lists
- Mixing permissions with system hardware details
Solution
Step 1: Identify what a row in access control matrix shows
A row lists a user and their permissions on various resources.Step 2: Check which option matches this format
User1: read, write shows a user with permissions, matching the row concept.Final Answer:
User1: read, write -> Option BQuick Check:
Row = user permissions list [OK]
- Confusing resource details with user permissions
- Mixing process or CPU info with access control
- Choosing options unrelated to permissions
Users\Files | File1 | File2
---------|--------|-------
Alice | read | write
Bob | write | executeWhat permission does Bob have on File2?
Solution
Step 1: Locate Bob's row in the matrix
Bob's permissions are listed in the second row.Step 2: Find the permission under File2 column for Bob
Bob has 'execute' permission on File2.Final Answer:
execute -> Option AQuick Check:
Bob on File2 = execute [OK]
- Mixing up rows and columns
- Choosing Alice's permissions instead of Bob's
- Assuming default permissions if not listed
Users\Resources | FileA | FileB
--------------|--------|-------
Carol | read | readwriteexecuteWhat is wrong with this matrix?
Solution
Step 1: Check how permissions are listed in each cell
Permissions should be clearly separated, usually by commas or listed distinctly.Step 2: Identify if combining multiple permissions in one cell is acceptable
Combining multiple permissions in one cell without clear separation can cause confusion.Final Answer:
Multiple permissions should be separated, not combined in one cell -> Option CQuick Check:
Permissions must be clearly separated [OK]
- Thinking users must be listed horizontally
- Assuming permissions can't be combined at all
- Ignoring formatting clarity in matrix
Report.doc, what is the best approach?Solution
Step 1: Understand matrix layout
Rows represent users, columns represent resources.Step 2: To find users who can write to Report.doc, check the column for that resource
Looking down the column shows which users have write permission.Final Answer:
Look down the column for Report.doc and note users with write permission -> Option DQuick Check:
Users with write on resource = column check [OK]
- Looking across a resource row instead of column
- Checking only diagonal cells
- Scanning entire matrix unnecessarily
Ready to prove it?
Pass the test and this pattern moves unknown
