I would like to use segmentation for allocating a fixed memory junk of a predefined contiguous memory region to each of my OS tasks.
For example, let's say that I use the 0x100000 - 0x120000 memory region. This region is of 128 KB so if I keep 64 KB for the kernel code, stack and data, and allocate 2KB to each task of the rest 64 KB, I will have 32+1 segments.

My understating says that apart from creating 33 GDT descriptors for the code and 33 for the data of each segment, I will need to define these segments in my linker script as well. Is that right?
First question: How am I mapping the data and code of a task into its segment?
E.g. Let's say that I want to have the code and data of Task A into its 2 KB segment. How can I achieve this? Should I use something like the keyword __attribute__ along with section attribute in GCC?
Second question: How am I restricting a task to change data only in its segment?
E.g. Task A should be able to affect only the data in its 2 KB segment and nothing else.
NOTE: I am aware of the paging alternative but I would like to use segmentation instead of paging.
Any help will be much appreciated.
Thanks in advance.

