[OSy] Fwd: Re: OS Assignment 4: System Calls
Petr Tůma
petr.tuma at d3s.mff.cuni.cz
Wed Dec 12 11:16:39 CET 2018
Forwarding in case it helps other people ... PT
-------- Forwarded Message --------
Subject: Re: OS Assignment 4: System Calls
Date: Mon, 10 Dec 2018 16:45:16 +0100
From: Petr Tůma <petr.tuma at d3s.mff.cuni.cz>
To: Immo Hellwig <immo.hellwig at stud.uni-goettingen.de>
Hi Immo,
thanks for the mail, here are some tips:
> 1. User Space malloc/free Implementation:
>
> The description says: "It is possible to port and reuse the existing Kalisto kernel heap
> allocator to user space, since the basic functionality is the same."
>
> How is this that possible, if we don't have a implementation of list in the userspace?
Why not copy the list implementation to userspace together with the memory allocator ? The implementation is in
a header file (list.h), there is no standalone C file, so simply copying list.h into the librt directory should
do the trick.
> 2. Blocking a process:
>
> I can't find a systemcall/function in thread.c for that. How I block a process?
I do not see this point in the assignment, can you please point me to what you need ? In general, a thread goes
to sleep by calling thread_suspend, is that what you had in mind ?
> 3. exit double implementation:
>
> Isn't exit already implemented in thread.c? Or do we have to extend it?
The exit function in userspace should completely terminate the executing process, including killing its other
threads. This is something the current sys_exit function does not do, so you should I think extend it.
> 4. rare usage of systemcalls:
>
> I dont get how using systemcalls can even be avoided. All functions provide some kernel functionality,
> that cant be implemented in user space. Is there a function that can be implemented without using a
> system call?
The point here is that some functions - in particular malloc and free - should not be implemented simply by
making a syscall, which would implement their complete functionality. Instead, for example malloc and free
should only need to make a syscall when they allocate pages using vma_map and vma_unmap. Most of the time,
malloc and free should work in previously allocated pages and therefore not make a syscall at all.
> 5. Usage of Systemcalls:
>
> char getc(void)
> {
> char from_buffer = (char) SYSCALL0(SYS_GETC);
> if (from_buffer == '\0') {
> //Block Thread
> } else {
> return from_buffer;
> }
> while ((from_buffer = (char) SYSCALL0(SYS_GETC)) == '\0') {}
> //Unblock Thread
> return from_buffer;
> }
>
> Locks the test in a loop. I'm not sure if the reason for that is the missing threadblock or if I am using
> the systemcall in a wrong way.
Looking into syscall.c, I see that the default implementation of sys_getc is empty, so you need to add that. I
think the waiting can be done inside the sys_getc implementation in the kernel too.
Let me know if this helps ?
Petr
More information about the NSWI004
mailing list