user_thread #9
@ -5,13 +5,14 @@
|
|||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "mmuContext.h"
|
#include "mmuContext.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "thread.h"
|
||||||
#include "uaddrspace.h"
|
#include "uaddrspace.h"
|
||||||
|
|
||||||
struct process {
|
struct process {
|
||||||
char name[PROCESS_NAME_MAX_LENGTH];
|
char name[PROCESS_NAME_MAX_LENGTH];
|
||||||
int ref;
|
int ref;
|
||||||
int pid;
|
pid_t pid;
|
||||||
int nextTid;
|
pid_t nextTid;
|
||||||
struct uAddrSpace *addrSpace;
|
struct uAddrSpace *addrSpace;
|
||||||
struct thread *thList;
|
struct thread *thList;
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ void processListPrint()
|
|||||||
struct thread *th;
|
struct thread *th;
|
||||||
int nbTh;
|
int nbTh;
|
||||||
|
|
||||||
printf("%d %s %d %d\n", proc->pid, proc->name, processCountThread(proc), proc->ref);
|
printf("%lu %s %d %d\n", proc->pid, proc->name, processCountThread(proc), proc->ref);
|
||||||
list_foreach_named(proc->thList, th, nbTh, prevInProcess, nextInProcess)
|
list_foreach_named(proc->thList, th, nbTh, prevInProcess, nextInProcess)
|
||||||
{
|
{
|
||||||
if (th == cur) {
|
if (th == cur) {
|
||||||
@ -183,10 +184,10 @@ int processInitHeap(struct process *proc, uaddr_t lastUserAddr){
|
|||||||
return uAddrSpaceSetHeap(proc->addrSpace, lastUserAddr, 0);
|
return uAddrSpaceSetHeap(proc->addrSpace, lastUserAddr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int processGetId(struct process *proc){
|
pid_t processGetId(struct process *proc){
|
||||||
return proc->pid;
|
return proc->pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int processGetNextTid(struct process *proc){
|
pid_t processGetNextTid(struct process *proc){
|
||||||
return proc->nextTid++;
|
return proc->nextTid++;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "thread.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define PROCESS_NAME_MAX_LENGTH 32
|
#define PROCESS_NAME_MAX_LENGTH 32
|
||||||
|
typedef unsigned long int pid_t;
|
||||||
|
|
||||||
struct process;
|
struct process;
|
||||||
|
struct thread;
|
||||||
|
|
||||||
int processSetup();
|
int processSetup();
|
||||||
struct process *processCreate(char *name);
|
struct process *processCreate(char *name);
|
||||||
@ -18,5 +20,5 @@ int processRemoveThread(struct thread *th);
|
|||||||
struct mmu_context *processGetMMUContext(struct process *th);
|
struct mmu_context *processGetMMUContext(struct process *th);
|
||||||
struct uAddrSpace *processGetAddrSpace(struct process *proc);
|
struct uAddrSpace *processGetAddrSpace(struct process *proc);
|
||||||
int processInitHeap(struct process *proc, uaddr_t lastUserAddr);
|
int processInitHeap(struct process *proc, uaddr_t lastUserAddr);
|
||||||
int processGetId(struct process *proc);
|
pid_t processGetId(struct process *proc);
|
||||||
int processGetNextTid(struct process *proc);
|
pid_t processGetNextTid(struct process *proc);
|
||||||
|
@ -14,7 +14,7 @@ static struct thread *currentThread;
|
|||||||
static struct thread *threadWithTimeout;
|
static struct thread *threadWithTimeout;
|
||||||
static thread_id_t nextTid; // This is the TID for kernel thread ONLY
|
static thread_id_t nextTid; // This is the TID for kernel thread ONLY
|
||||||
|
|
||||||
thread_id_t threadGetId(struct thread *th)
|
pid_t threadGetId(struct thread *th)
|
||||||
{
|
{
|
||||||
return th->tid;
|
return th->tid;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "mmuContext.h"
|
#include "mmuContext.h"
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
|
#include "stddef.h"
|
||||||
|
#include "stdint.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
struct uAddrSpace;
|
struct uAddrSpace;
|
||||||
struct uAddrVirtualReg;
|
struct uAddrVirtualReg;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "klibc.h"
|
#include "klibc.h"
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
struct zeroMappedEntry {
|
struct zeroMappedEntry {
|
||||||
int refCnt;
|
int refCnt;
|
||||||
|
@ -123,7 +123,7 @@ int func_munmap()
|
|||||||
|
|
||||||
static void *print_hello(void *arg) {
|
static void *print_hello(void *arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
printf("Hello World from thread %d\n", gettid());
|
printf("Hello World from thread %lu\n", gettid());
|
||||||
usleep(100);
|
usleep(100);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
typedef unsigned int useconds_t;
|
typedef unsigned int useconds_t;
|
||||||
int usleep(useconds_t usec);
|
int usleep(useconds_t usec);
|
||||||
|
|
||||||
typedef int pid_t;
|
typedef unsigned long int pid_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user