RTAI API Inter Process Communication
|
|
|
- Miranda Norris
- 10 years ago
- Views:
Transcription
1 RTAI API Inter Process Communication Antonio Barbalace Overview Semaphores Shared Memory FIFOs Mailbox Typed Mailbox Messages POSIX Message Queue Antonio Barbalace 2009 RTOS - RTAI course 2
2 Semaphores A semaphore can be used for communication and synchronization among real time tasks. RTAI supports different kind of semaphores: CNT_SEM counting semaphores; BIN_SEM binary semaphores; RES_SEM resource semaphores; All orred combination of such semaphores. Mutexes are implemented by semaphores. RTAI supports different queuing policy: FIFO_Q for a fifo queuing; PRIO_Q for a priority queuing. Resource semaphores will enforce a PRIO_Q policy anyhow. Negative values of a semaphore show how many tasks are blocked on the semaphore queue, waiting to be awaken. Antonio Barbalace 2009 RTOS - RTAI course 3 Semaphores Prototypes in rtai_sem.h void rt_sem_init(sem *sem, int value) int rt_sem_delete(sem *sem) int rt_sem_signal(sem *sem) int rt_sem_broadcast(sem *sem) int rt_sem_wait(sem *sem) int rt_sem_wait_if(sem *sem) int rt_sem_wait_until(sem *sem, RTIME time) int rt_sem_wait_timed(sem *sem, RTIME delay) Antonio Barbalace 2009 RTOS - RTAI course 4
3 Semaphores Example file sem_example.c /* sem_example.c */ #define TASK_PRIORITY 1 #define TASK_PERIOD 2E9 #define STACK_SIZE 2000 #include <rtai.h> #include <rtai_sem.h> #include <rtai_sched.h> MODULE_LICENSE( GPL ); static RT_TASK rt_task_send; static RT_TASK rt_task_recv; static int global_rt_data; static SEM rt_sem; void task_sender(int t) { while(1) { rt_sem_wait(&rt_sem); global_rt_data++; rt_printk("sender (INC) %d\n", global_rt_data); rt_sem_signal(&rt_sem); void task_receiver(int t) { while(1) { rt_sem_wait(&rt_sem); rt_busy_sleep(1000); rt_printk("receiver (read) %d\n", global_rt_data); rt_sem_signal(&rt_sem); static int module_init(void) { rt_sem_init(&rt_sem, 1); rt_task_init(&rt_task_send, task_sender, 0, STACK_SIZE, TASK_PRIORITY, 0, 0); rt_task_init(&rt_task_recv, task_receiver, 0, STACK_SIZE, TASK_PRIORITY, 0, 0); rt_set_periodic_mode(); int period = start_rt_timer(nano2count(task_period)); RTIME time = rt_get_time(); rt_task_make_periodic(&rt_task_send, (time + period + 2), period); rt_task_make_periodic(&rt_task_recv, (time + period), period); static void module_exit(void) { rt_sem_delete(&rt_sem); stop_rt_timer(); rt_busy_sleep(nano2count(1e7)); rt_task_delete(&rt_task_send); rt_busy_sleep(nano2count(1e7)); rt_task_delete(&rt_task_recv); Antonio Barbalace 2009 RTOS - RTAI course 5 Semaphores Semaphores code in RTAI also implements: Barriers Conditional Variables Readers-Writers Locks Recursive Spinlocks Antonio Barbalace 2009 RTOS - RTAI course 6
4 Shared Memory The allocation of a shared memory between tasks in kernel space is trivial: since the address space is the same, common memory allocation functions are used. RTAI has a specific module that allows the overall symmetric allocation and sharing of memory inter/intra-kernel/user space; any pair of memory sharing is possible between the following: RTAI proper tasks, Linux kernel threads, Linux user space processes, LXRT tasks. All memory expansion requests are managed dynamically, but they will not impact real time performance, since they are deferred to be serviced when the Linux context is restored. Prototypes in rtai_shm.h void *rt_shm_alloc(unsigned long name, int size, int suprt); void *rt_shm_alloc_adr(void *start, unsigned long name, int size, int suprt); int rt_shm_free(unsigned long name); Antonio Barbalace 2009 RTOS - RTAI course 7 Shared Memory Example file shm_example.c /* shm_example.c */ #include <rtai.h> #include <rtai_sched.h> #include <rtai_shm.h> #include shm_example.h" MODULE_LICENSE( GPL ); static RT_TASK rt_task; static struct data_str *data; static void fun(int t) { unsigned int count = 0; int sen,cos; while (1) { data->indx_counter = count; sen = count%20*((-1)<<count)*24; cos = -count%20*((-1)<<count)*24; data->sin_value = sen; data->cos_value = cos; count++; int module_init(void) { RTIME tick_period; rt_set_periodic_mode(); rt_task_init(&rt_task, fun, 1, STACK_SIZE, TASK_PRIORITY, 1, 0); data = rt_shm_alloc(nam2num(shmnam), sizeof(struct data_str), USE_VMALLOC); tick_period = start_rt_timer(nano2count(tick_period)); rt_task_make_periodic(&rt_task, rt_get_time() + tick_period, tick_period); void cleanup_module(void){ stop_rt_timer(); rt_task_delete(&rt_task); rt_shm_free(nam2num(shmnam)); return; file shm_example.h file shm_usr.c /* shm_usr.c */ #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> #include <rtai_shm.h> #include shm_example.h" static int end; static void endme(int dummy) { end=1; int main (void){ struct data_str *data; signal(sigint, endme); data = rt_shm_alloc(nam2num(shmnam),sizeof(struct data_str), USE_VMALLOC); while (!end) { printf(" Counter : %d Sine : %d Cosine : %d \n", data->indx_counter, data->sin_value, data- >cos_value); rt_shm_free(nam2num(shmnam)); /* shm_example.h */ #define TICK_PERIOD #define TASK_PRIORITY 1 #define STACK_SIZE #define SHMNAM "MIRSHM" struct data_str{ int indx_counter; int sin_value; int cos_value; ; Antonio Barbalace 2009 RTOS - RTAI course 8
5 FIFO A RT FIFO is a point-to-point link connecting one real-time task to one Linux process. It s very much like a Unix pipe. The implementation allows a FIFO to be bidirectional, but in practice that rarely makes sense. Suppose, for example, that one end of the FIFO writes a command and then immediately tries to read the result of the command it just wrote. Chances are it would just read back the command it wrote. So in practice, FIFOs are unidirectional where the direction is established by the programmer. In the example just cited, you would create two FIFOs, one to send the command and the other to read the response. User Space processes treat a RT FIFOs as character devices, /dev/rtf0 to /dev/rtf63. A process opens a FIFO for reading or writing and then uses read() or write() on the file descriptor to transfer data. Real-time tasks access the FIFO through an RTAI-specific API. Antonio Barbalace 2009 RTOS - RTAI course 9 FIFO In Linux, FIFOs have to be created by $ mknod /dev/rtf<x> c 150 <x> where <x> is the minor device number, from 0 to 63. What is important to remember is that in user space you address fifos through the file descriptor you get at fifo device opening, while in kernel space you directly address them by their minor number. So you will mate the file descriptor you get in user space by using open(/dev/rtfxx,...) to the integer xx you will use in kernel space. RTAI fifos should be used just with applications that use only real time interrupt handlers, so that no RTAI scheduler is installed. To monitor the FIFO usage, RTAI has the /proc/rtai/fifo interface. Antonio Barbalace 2009 RTOS - RTAI course 10
6 FIFO Prototypes in rtai_fifos.h int rtf_create(unsigned int fifo, int size); int rtf_destroy(unsigned int fifo); int rtf_getfifobyname(const char *name); int rtf_reset(unsigned int fifo); int rtf_resize(unsigned int minor, int size); int rtf_put(unsigned int fifo, /* RT-FIFO */ void * buf, /* buffer address */ int count /* number of bytes to write */); int rtf_get(unsigned int fifo, /* RT-FIFO */ void * buf, /* buffer address */ int count /* number of bytes to read */); Antonio Barbalace 2009 RTOS - RTAI course 11 FIFO Example file fifo_example.c /* fifo_example.c */ #include <rtai.h> #include <rtai_sched.h> #include <rtai_fifos.h> #define TICK_PERIOD #define TASK_PRIORITY 1 #define STACK_SIZE #define FIFO 0 MODULE_LICENSE( GPL ); static RT_TASK rt_task; static void fun(int t) { int counter = 0; int sin_value = 3; while (1) { sin_value++; rtf_put(fifo, &counter, sizeof(counter)); rtf_put(fifo, &sin_value, sizeof(sin_value)); counter++; static int module_init(void) { int result; RTIME tick_period; rt_set_periodic_mode(); if (result = rt_task_init(&rt_task, fun, 0, STACK_SIZE, TASK_PRIORITY, 0, 0)!=0) { printk("<0> Errore init\n"); return EIO; rtf_create(fifo, 8000); tick_period = start_rt_timer(nano2count(tick_period)); rt_task_make_periodic(&rt_task, rt_get_time() + tick_period, tick_period); static void module_exit(void) { stop_rt_timer(); rtf_destroy(fifo); rt_task_delete(&rt_task); return; file fifo_usr.c /* fifo_usr.c */ #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> static int end; static void endme(int dummy) { end=1; int main (void){ int fifo, counter; int sin_value; if ((fifo = open("/dev/rtf/0", O_RDONLY)) < 0) { fprintf(stderr, "Error opening /dev/rtf/0\n"); exit(1); signal(sigint, endme); while (!end) { read(fifo, &counter, sizeof(counter)); read(fifo, &sin_value, sizeof(sin_value)); printf(" Counter : %d Sin : %d \n", counter, sin_value); Antonio Barbalace 2009 RTOS - RTAI course 12
7 Mailbox Using mailboxes is a flexible method for inter task communications. A mailbox is created with an initial size. Tasks are allowed to send arbitrarily sized messages by using any mailbox buffer size. There is even no need to use a buffer sized at least as the largest message you envisage, even if efficiency is likely to suffer from such a decision. However if you expect a message larger than the average message size very rarely, then you can use a smaller buffer without much loss of efficiency. This allows you to set up your own mailbox usage protocol; e.g. using fixed sized messages, with a buffer size that is a multiple of the size of messages, guarantees maximum efficiency by having each message sent/received atomically to/from the mailbox. Multiple senders and receivers are allowed and each will get the service it requires in turn, according to its priority. Thus mailboxes provide a flexible mechanism to allow you to freely implement your own policy. Antonio Barbalace 2009 RTOS - RTAI course 13 Mailbox Prototypes in rtai_mbx.h int rt_mbx_init(struct rt_mailbox *mbx, int size) int rt_mbx_delete(struct rt_mailbox *mbx) int rt_mbx_send(struct rt_mailbox *mbx, void *msg, int msg_size) int rt_mbx_send_wp(struct rt_mailbox *mbx, void *msg, int msg_size) int rt_mbx_send_if(struct rt_mailbox *mbx, void *msg, int msg_size) int rt_mbx_send_until(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME time) int rt_mbx_send_timed(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME delay) int rt_mbx_ovrwr_send(struct rt_mailbox *mbx, void *msg, int msg_size) int rt_mbx_receive(struct rt_mailbox *mbx, void *msg, int msg_size) int rt_mbx_receive_wp(struct rt_mailbox *mbx, void *msg, int msg_size) int rt_mbx_receive_if(struct rt_mailbox *mbx, void *msg, int msg_size) int rt_mbx_receive_until(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME time) int rt_mbx_receive_timed(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME delay) Antonio Barbalace 2009 RTOS - RTAI course 14
8 Mailbox Example file mbx_example.c /* mbx_example.c */ #define TASK_PRIORITY 0 #define TASK_PERIOD 2E9 #define JITTER 10 #define STACK_SIZE 2000 #include <rtai.h> #include <rtai_sched.h> #include <rtai_mbx.h> MODULE_LICENSE( GPL ); typedef struct message { int count; RTIME sender; RTIME receiver; MSG; static RT_TASK rt_task_send; static RT_TASK rt_task_recv; MBX mbx; void task_sender(int t) { int result; int counter = 0; MSG send_msg = {0, 0, 0; while(1) { send_msg.count = counter++; send_msg.sender = rt_get_time(); result = rt_mbx_send(&mbx, &send_msg, sizeof(msg)); if (!(result==sizeof(msg) result==0)) { rt_printk( send error\n ); continue; ; rt_printk("%ssender: msg SENT count: %d time: %d\n", DEBUG_P, send_msg.count, send_msg.sender); void task_receiv(int t) { int result; MSG recv_msg = {0, 0, 0; while(1){ result = rt_mbx_receive(&mbx, &recv_msg, sizeof(msg)); if (!(result==sizeof(msg) result==0)) { rt_printk( recv error\n ); continue; recv_msg.receiver = rt_get_time(); rt_printk("%sreceiver: msg RECV count: %d times: %d timer: %d\n", DEBUG_P, recv_msg.count, recv_msg.sender, recv_msg.receiver); static int module_init(void) { int result; if((result = rt_mbx_init(&mbx, sizeof(msg)))!=0) { printk("%sinit ERROR no too space for buffer mailbox\n", DEBUG_P); return EIO; rt_task_init(&rt_task_send, task_sender, 0, STACK_SIZE, TASK_PRIORITY, 0, 0); rt_task_init(&rt_task_recv, task_receiv, 0, STACK_SIZE, TASK_PRIORITY, 0, 0); printk("%speriodic MODE enabled\n", DEBUG_P); rt_set_periodic_mode(); int period = start_rt_timer(nano2count(task_period)); RTIME time = rt_get_time(); rt_task_make_periodic(&rt_task_send, time + period, period); rt_task_make_periodic(&rt_task_recv, time + period + JITTER, period); static void cleanup_module(void) { stop_rt_timer(); rt_busy_sleep(nano2count(1e7)); rt_task_delete(&rt_task_send); rt_busy_sleep(nano2count(1e7)); rt_task_delete(&rt_task_recv); Antonio Barbalace 2009 RTOS - RTAI course 15 Typed Mailbox Typed mailboxes (TBX) are an alternative to the default RTAI ones. Typed mailboxes offer: 1. Message broadcasting, that is sending a message to ALL the tasks that are pending on the same TBX. 2. Urgent sending of messages: these messages are not queued, but are inserted at the head of the queue, bypassing all the other messages already present in TBX. 3. The possibility to set up the PRIORITY/FIFO wakeup policy at runtime, when creating the TBX. Features (1) and (2) are achieved by adding a type field (1 byte) to every message inserted in a TBX: this byte makes it possible to discriminate normal, urgent and broadcast messages, when they are received. The type field is removed by the receiving functions, so from the user point of view it is not visible. Users must consider type fields only when specifying the TBX sizes. Antonio Barbalace 2009 RTOS - RTAI course 16
9 int rt_tbx_init(tbx, size, flags) int rt_tbx_delete(tbx) Typed Mailbox Prototypes in rtai_tbx.h int rt_tbx_send(tbx, msg, msg_size) * int rt_tbx_receive(tbx, msg, msg_size) * int rt_tbx_broadcast(tbx, msg, msg_size) * int rt_tbx_urgent(tbx, msg, msg_size) * rt_tbx_*_if rt_tbx_*_until rt_tbx_*_timed Antonio Barbalace 2009 RTOS - RTAI course 17 Typed Mailbox Example file tbx_example.c #include <rtai.h> #include <rtai_sched.h> #include <rtai_tbx.h> static RT_TASK mtask_0, mtask_1, btask, wdog; static TBX smbx, rmbx[2]; static unsigned long long name [2] = { 0xaaaaaaaaaaaaaaaaLL, 0xbbbbbbbbbbbbbbbbLL; static int stop, alarm; void wfun (int t) { while(stop) { if (alarm &&!stop) { stop = 1; rt_printk("locked\n"); alarm = 1; void mfun(int t) { unsigned long long msg; while(stop) { alarm = 0; rt_tbx_send_timed(&smbx, &name[t], sizeof(long long), nano2count( )); msg = 0; rt_tbx_receive_timed(&rmbx[t], &msg, sizeof(msg), nano2count( )); if(msg!= 0xccccccccccccccccLL) rt_printk(">em %d %d<\n", t, stop); rt_busy_sleep( ); void bfun(int t){ int result = 0; unsigned long long msg; unsigned long long name = 0xccccccccccccccccLL; while (stop) { alarm = 0; if((result = rt_tbx_receive(&smbx, &msg, sizeof(msg)))!=sizeof(msg)) { rt_printk( bfun error %x \n", result); if (msg == 0xaaaaaaaaaaaaaaaaLL) t = 0; else if (msg==0xbbbbbbbbbbbbbbbbll) t = 1; else { rt_printk(">eb %x %x<\n", ((int *) &msg)[0], ((int *) &msg)[1]); t = 0; ; rt_tbx_send(&rmbx[t], &name, sizeof(name)); static int module_init(void) { RTIME period; int result; if ((result = rt_tbx_init(&smbx, 5, 0))!=0) { rt_printk("error smbx %u\n", result); if ((result = rt_tbx_init(&rmbx[0], 1, 0))!=0) { rt_printk("error rmbx 0 %u\n", result); if ((result = rt_tbx_init(&rmbx[1], 3, 0))!=0) { rt_printk("error rmbx 1 %u\n", result); rt_task_init(&wdog, wfun, 0, 2000, 0, 0, 0); rt_task_init(&mtask_0, mfun, 0, 2000, 0, 0, 0); rt_task_init(&mtask_1, mfun, 1, 2000, 0, 0, 0); rt_task_init(&btask, bfun, 0, 2000, 0, 0, 0); alarm = 0; stop = 1; rt_set_oneshot_mode(); period = start_rt_timer(nano2count(2e9)); rt_task_make_periodic(&wdog, rt_get_time() + period, period); rt_task_resume(&btask); rt_task_resume(&mtask_0); rt_task_resume(&mtask_1); static module_exit(void){ stop = 0; rt_busy_sleep(nano2count(1e7)); stop_rt_timer(); rt_tbx_delete(&smbx); rt_tbx_delete(&rmbx[0]); rt_tbx_delete(&rmbx[1]); rt_task_delete(&mtask_0); rt_task_delete(&mtask_1); rt_task_delete(&btask); rt_task_delete(&wdog); Antonio Barbalace 2009 RTOS - RTAI course 18
10 Messages Messages are the native way to communicate between RTAI task. The RTAI task descriptor is used as the holder of the message. Antonio Barbalace 2009 RTOS - RTAI course 19 Messages Prototypes in rtai_msg.h struct rt_task_struct *rt_send(struct rt_task_struct *task, unsigned long msg); struct rt_task_struct *rt_send_if(struct rt_task_struct *task, unsigned long msg); struct rt_task_struct *rt_send_until(struct rt_task_struct *task, unsigned long msg, RTIME time); struct rt_task_struct *rt_send_timed(struct rt_task_struct *task, unsigned long msg, RTIME delay); struct rt_task_struct *rt_evdrp(struct rt_task_struct *task, void *msg); struct rt_task_struct *rt_receive(struct rt_task_struct *task, void *msg); struct rt_task_struct *rt_receive_if(struct rt_task_struct *task, void *msg); struct rt_task_struct *rt_receive_until(struct rt_task_struct *task, void *msg, RTIME time); struct rt_task_struct *rt_receive_timed(struct rt_task_struct *task, void *msg, RTIME delay); Antonio Barbalace 2009 RTOS - RTAI course 20
11 Messages Example file msg_example.c #define TASK_PRIORITY 0 #define TASK_PERIOD 2E9 #define STACK_SIZE 2000 #include <rtai.h> #include <rtai_sched.h> MODULE_LICENSE( GPL ); int jitter = 1; typedef struct message { int count; int sender; int receiver; MSG; RT_TASK rt_task_send; RT_TASK rt_task_recv; void task_sender(int t); void task_receiv(int t); void task_sender(int t){ int result; int counter = 0; MSG send_msg = {0, 0, 0; while(1) { send_msg.count = counter++; send_msg.sender = rt_get_time(); if(((rt_task*)result = rt_send(&rt_task_recv, &send_msg))!=&rt_task_recv) rt_printk( task_sender sender ERROR\n"); rt_printk("%ssender: msg SENT count: %d time: %u r: %d ptr: %d\n", DEBUG_P, send_msg.count, send_msg.sender, result, &rt_task_recv); void task_receiv(int t){ int result; int time0, time1; void *msg; MSG recv_msg={0, 0, 0; while(1) { time0 = rt_get_time(); if(((rt_task*)result = rt_receive(&rt_task_send, msg))!=&rt_task_send) rt_printk( task_recv receiv ERROR\n"); time1 = rt_get_time(); rt_return(&rt_task_send, 0);//? memcpy(&recv_msg, msg, sizeof(msg)); recv_msg.receiver = time1; rt_printk("%sreceiver: msg RECV count: %d times: %u timer: %u time: %ucount time: %u elapsed: %d\n", DEBUG_P, recv_msg.count, recv_msg.sender, recv_msg.receiver, recv_msg.receiver - recv_msg.sender, time0, time0 - recv_msg.receiver); static int module_init (void) { rt_task_init(&rt_task_send, task_sender, 0, STACK_SIZE, TASK_PRIORITY, 0, 0); rt_task_init(&rt_task_recv, task_receiv, 0, STACK_SIZE, TASK_PRIORITY+1, 0, 0); printk("%speriodic MODE enabled assuming jitter: %d\n", DEBUG_P, jitter); rt_set_periodic_mode(); int period = start_rt_timer(nano2count(task_period)); RTIME time = rt_get_time(); rt_task_make_periodic(&rt_task_send, time + period, period); rt_task_make_periodic(&rt_task_recv, time + period + jitter, period); static void module_exit(void) { stop_rt_timer(); rt_busy_sleep(nano2count(1e7)); rt_task_delete(&rt_task_send); rt_busy_sleep(nano2count(1e7)); rt_task_delete(&rt_task_recv); Antonio Barbalace 2009 RTOS - RTAI course 21 Message Queue Added in RTAI to support POSIX Message Queue standard. Antonio Barbalace 2009 RTOS - RTAI course 22
12 Message Queue Prototypes in rtai_mq.h mqd_t mq_open(char *mq_name, int oflags, mode_t permissions, struct mq_attr *mq_attr) int mq_close(mqd_t mq) int mq_getattr(mqd_t mq, struct mq_attr *attrbuf) int mq_setattr(mqd_t mq, const struct mq_attr *new_attrs, struct mq_attr *old_attrs) int mq_notify(mqd_t mq, const struct sigevent *notification) int mq_unlink(char *mq_name) size_t mq_receive(mqd_t mq, char *msg_buffer, size_t buflen, unsigned int *msgprio) int mq_send(mqd_t mq, const char *msg, size_t msglen, unsigned int msgprio) size_t mq_timedreceive(mqd_t mq, char *msg_buffer, size_t buflen, unsigned int *msgprio, const struct timespec *abstime) int mq_timedsend(mqd_t mq, const char *msg, size_t msglen, unsigned int msgprio, const struct timespec *abstime) Antonio Barbalace 2009 RTOS - RTAI course 23 Message Queue Example See POSIX.1b for examples... Antonio Barbalace 2009 RTOS - RTAI course 24
OS: IPC I. Cooperating Processes. CIT 595 Spring 2010. Message Passing vs. Shared Memory. Message Passing: Unix Pipes
Cooperating Processes Independent processes cannot affect or be affected by the execution of another process OS: IPC I CIT 595 Spring 2010 Cooperating process can affect or be affected by the execution
What is an RTOS? Introduction to Real-Time Operating Systems. So what is an RTOS?(contd)
Introduction to Real-Time Operating Systems Mahesh Balasubramaniam What is an RTOS? An RTOS is a class of operating systems that are intended for real time-applications What is a real time application?
RTAI. Antonio Barbalace [email protected]. (modified by M.Moro 2011) RTAI
Antonio Barbalace [email protected] (modified by M.Moro 2011) Real Time Application Interface by Dipartimento di Ingegneria Aereospaziale dell Università di Milano (DIAPM) It is not a complete
System Calls Related to File Manipulation
KING FAHD UNIVERSITY OF PETROLEUM AND MINERALS Information and Computer Science Department ICS 431 Operating Systems Lab # 12 System Calls Related to File Manipulation Objective: In this lab we will be
Lecture 6: Semaphores and Monitors
HW 2 Due Tuesday 10/18 Lecture 6: Semaphores and Monitors CSE 120: Principles of Operating Systems Alex C. Snoeren Higher-Level Synchronization We looked at using locks to provide mutual exclusion Locks
Jorix kernel: real-time scheduling
Jorix kernel: real-time scheduling Joris Huizer Kwie Min Wong May 16, 2007 1 Introduction As a specialized part of the kernel, we implemented two real-time scheduling algorithms: RM (rate monotonic) and
Linux/UNIX System Programming. POSIX Shared Memory. Michael Kerrisk, man7.org c 2015. February 2015
Linux/UNIX System Programming POSIX Shared Memory Michael Kerrisk, man7.org c 2015 February 2015 Outline 22 POSIX Shared Memory 22-1 22.1 Overview 22-3 22.2 Creating and opening shared memory objects 22-10
System Calls and Standard I/O
System Calls and Standard I/O Professor Jennifer Rexford http://www.cs.princeton.edu/~jrex 1 Goals of Today s Class System calls o How a user process contacts the Operating System o For advanced services
Shared Memory Segments and POSIX Semaphores 1
Shared Memory Segments and POSIX Semaphores 1 Alex Delis delis -at+ pitt.edu October 2012 1 Acknowledgements to Prof. T. Stamatopoulos, M. Avidor, Prof. A. Deligiannakis, S. Evangelatos, Dr. V. Kanitkar
XMOS Programming Guide
XMOS Programming Guide Document Number: Publication Date: 2014/10/9 XMOS 2014, All Rights Reserved. XMOS Programming Guide 2/108 SYNOPSIS This document provides a consolidated guide on how to program XMOS
Linux Kernel Networking. Raoul Rivas
Linux Kernel Networking Raoul Rivas Kernel vs Application Programming No memory protection Memory Protection We share memory with devices, scheduler Sometimes no preemption Can hog the CPU Segmentation
Outline. Review. Inter process communication Signals Fork Pipes FIFO. Spotlights
Outline Review Inter process communication Signals Fork Pipes FIFO Spotlights 1 6.087 Lecture 14 January 29, 2010 Review Inter process communication Signals Fork Pipes FIFO Spotlights 2 Review: multithreading
Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture
Last Class: OS and Computer Architecture System bus Network card CPU, memory, I/O devices, network card, system bus Lecture 3, page 1 Last Class: OS and Computer Architecture OS Service Protection Interrupts
Socket Programming. Srinidhi Varadarajan
Socket Programming Srinidhi Varadarajan Client-server paradigm Client: initiates contact with server ( speaks first ) typically requests service from server, for Web, client is implemented in browser;
Linux Driver Devices. Why, When, Which, How?
Bertrand Mermet Sylvain Ract Linux Driver Devices. Why, When, Which, How? Since its creation in the early 1990 s Linux has been installed on millions of computers or embedded systems. These systems may
Tasks Schedule Analysis in RTAI/Linux-GPL
Tasks Schedule Analysis in RTAI/Linux-GPL Claudio Aciti and Nelson Acosta INTIA - Depto de Computación y Sistemas - Facultad de Ciencias Exactas Universidad Nacional del Centro de la Provincia de Buenos
Real Time Programming: Concepts
Real Time Programming: Concepts Radek Pelánek Plan at first we will study basic concepts related to real time programming then we will have a look at specific programming languages and study how they realize
MQX Lite Real-Time Operating System User Guide
MQX Lite Real-Time Operating System User Guide Document Number: MQXLITEUG Rev 1.1, 02/2014 2 Freescale Semiconductor, Inc. Contents Section number Title Page Chapter 1 Introduction 1.1 Overview of MQX
MatrixSSL Porting Guide
MatrixSSL Porting Guide Electronic versions are uncontrolled unless directly accessed from the QA Document Control system. Printed version are uncontrolled except when stamped with VALID COPY in red. External
Introduction. dnotify
Introduction In a multi-user, multi-process operating system, files are continually being created, modified and deleted, often by apparently unrelated processes. This means that any software that needs
Socket Programming. Kameswari Chebrolu Dept. of Electrical Engineering, IIT Kanpur
Socket Programming Kameswari Chebrolu Dept. of Electrical Engineering, IIT Kanpur Background Demultiplexing Convert host-to-host packet delivery service into a process-to-process communication channel
Embedded Systems. 6. Real-Time Operating Systems
Embedded Systems 6. Real-Time Operating Systems Lothar Thiele 6-1 Contents of Course 1. Embedded Systems Introduction 2. Software Introduction 7. System Components 10. Models 3. Real-Time Models 4. Periodic/Aperiodic
Networks. Inter-process Communication. Pipes. Inter-process Communication
Networks Mechanism by which two processes exchange information and coordinate activities Inter-process Communication process CS 217 process Network 1 2 Inter-process Communication Sockets o Processes can
Shared Memory Introduction
12 Shared Memory Introduction 12.1 Introduction Shared memory is the fastest form of IPC available. Once the memory is mapped into the address space of the processes that are sharing the memory region,
Lecture 24 Systems Programming in C
Lecture 24 Systems Programming in C A process is a currently executing instance of a program. All programs by default execute in the user mode. A C program can invoke UNIX system calls directly. A system
Mutual Exclusion using Monitors
Mutual Exclusion using Monitors Some programming languages, such as Concurrent Pascal, Modula-2 and Java provide mutual exclusion facilities called monitors. They are similar to modules in languages that
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive
Kernel Synchronization and Interrupt Handling
Kernel Synchronization and Interrupt Handling Oliver Sengpie, Jan van Esdonk Arbeitsbereich Wissenschaftliches Rechnen Fachbereich Informatik Fakultt fr Mathematik, Informatik und Naturwissenschaften Universitt
Unix Network Programming
Introduction to Computer Networks Polly Huang EE NTU http://cc.ee.ntu.edu.tw/~phuang [email protected] Unix Network Programming The socket struct and data handling System calls Based on Beej's Guide
Linux Scheduler. Linux Scheduler
or or Affinity Basic Interactive es 1 / 40 Reality... or or Affinity Basic Interactive es The Linux scheduler tries to be very efficient To do that, it uses some complex data structures Some of what it
Migration of Process Credentials
C H A P T E R - 5 Migration of Process Credentials 5.1 Introduction 5.2 The Process Identifier 5.3 The Mechanism 5.4 Concluding Remarks 100 CHAPTER 5 Migration of Process Credentials 5.1 Introduction Every
3.5. cmsg Developer s Guide. Data Acquisition Group JEFFERSON LAB. Version
Version 3.5 JEFFERSON LAB Data Acquisition Group cmsg Developer s Guide J E F F E R S O N L A B D A T A A C Q U I S I T I O N G R O U P cmsg Developer s Guide Elliott Wolin [email protected] Carl Timmer [email protected]
REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux. Lesson-12: Real Time Linux
REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux Lesson-12: Real Time Linux 1 1. Real Time Linux 2 Linux 2.6.x Linux is after Linus Torvalds, father of the Linux operating
SYSTEM ecos Embedded Configurable Operating System
BELONGS TO THE CYGNUS SOLUTIONS founded about 1989 initiative connected with an idea of free software ( commercial support for the free software ). Recently merged with RedHat. CYGNUS was also the original
The POSIX Socket API
The POSIX Giovanni Agosta Piattaforme Software per la Rete Modulo 2 G. Agosta The POSIX Outline Sockets & TCP Connections 1 Sockets & TCP Connections 2 3 4 G. Agosta The POSIX TCP Connections Preliminaries
Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6
Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6 Winter Term 2008 / 2009 Jun.-Prof. Dr. André Brinkmann [email protected] Universität Paderborn PC² Agenda Multiprocessor and
Operating Systems and Networks
recap Operating Systems and Networks How OS manages multiple tasks Virtual memory Brief Linux demo Lecture 04: Introduction to OS-part 3 Behzad Bordbar 47 48 Contents Dual mode API to wrap system calls
Green Telnet. Making the Client/Server Model Green
Green Telnet Reducing energy consumption is of growing importance. Jeremy and Ken create a "green telnet" that lets clients transition to a low-power, sleep state. By Jeremy Blackburn and Ken Christensen,
Unix System Calls. Dept. CSIE 2006.12.25
Unix System Calls Gwan-Hwan Hwang Dept. CSIE National Taiwan Normal University 2006.12.25 UNIX System Overview UNIX Architecture Login Name Shells Files and Directories File System Filename Pathname Working
Shared Address Space Computing: Programming
Shared Address Space Computing: Programming Alistair Rendell See Chapter 6 or Lin and Synder, Chapter 7 of Grama, Gupta, Karypis and Kumar, and Chapter 8 of Wilkinson and Allen Fork/Join Programming Model
Threads Scheduling on Linux Operating Systems
Threads Scheduling on Linux Operating Systems Igli Tafa 1, Stavri Thomollari 2, Julian Fejzaj 3 Polytechnic University of Tirana, Faculty of Information Technology 1,2 University of Tirana, Faculty of
Operating System Manual. Realtime Communication System for netx. Kernel API Function Reference. www.hilscher.com.
Operating System Manual Realtime Communication System for netx Kernel API Function Reference Language: English www.hilscher.com rcx - Kernel API Function Reference 2 Copyright Information Copyright 2005-2007
Priority Based Implementation in Pintos
Priority Based Implementation in Pintos Deepa D 1, Nivas K S 2, Preethi V 3 1, 2, 3 Students M-Tech, Dept. of Information Technology, SNS College of Engg., Coimbatore. Abstract Pintos is a simple operating
Computer Networks Network architecture
Computer Networks Network architecture Saad Mneimneh Computer Science Hunter College of CUNY New York - Networks are like onions - They stink? - Yes, no, they have layers Shrek and Donkey 1 Introduction
1 Abstract Data Types Information Hiding
1 1 Abstract Data Types Information Hiding 1.1 Data Types Data types are an integral part of every programming language. ANSI-C has int, double and char to name just a few. Programmers are rarely content
Programmation Systèmes Cours 7 IPC: FIFO
Programmation Systèmes Cours 7 IPC: FIFO Stefano Zacchiroli [email protected] Laboratoire PPS, Université Paris Diderot - Paris 7 15 novembre 2011 URL http://upsilon.cc/zack/teaching/1112/progsyst/ Copyright
Introduction to Socket programming using C
Introduction to Socket programming using C Goal: learn how to build client/server application that communicate using sockets Vinay Narasimhamurthy [email protected] CLIENT SERVER MODEL Sockets are
The RTLinux Manifesto
The RTLinux Manifesto Victor Yodaiken Department of Computer Science New Mexico Institute of Technology Socorro NM 87801 [email protected] http://www.rtlinux.org ABSTRACT RTLinux is the hard realtime
ICT SEcurity BASICS. Course: Software Defined Radio. Angelo Liguori. SP4TE lab. [email protected]
Course: Software Defined Radio ICT SEcurity BASICS Angelo Liguori [email protected] SP4TE lab 1 Simple Timing Covert Channel Unintended information about data gets leaked through observing the
SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (I)
SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (I) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics
TivaWare Utilities Library
TivaWare Utilities Library USER S GUIDE SW-TM4C-UTILS-UG-1.1 Copyright 2013 Texas Instruments Incorporated Copyright Copyright 2013 Texas Instruments Incorporated. All rights reserved. Tiva and TivaWare
Process definition Concurrency Process status Process attributes PROCESES 1.3
Process Management Outline Main concepts Basic services for process management (Linux based) Inter process communications: Linux Signals and synchronization Internal process management Basic data structures:
ELEN 602: Computer Communications and Networking. Socket Programming Basics
1 ELEN 602: Computer Communications and Networking Socket Programming Basics A. Introduction In the classic client-server model, the client sends out requests to the server, and the server does some processing
Device Management API for Windows* and Linux* Operating Systems
Device Management API for Windows* and Linux* Operating Systems Library Reference September 2004 05-2222-002 INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE, EXPRESS
1 Operating Systems Prof. Dr. Marc H. Scholl DBIS U KN Summer Term 2009. IPC may often be used for both
Intended Schedule V. IPC: Inter-Process Communication Date Lecture Hand out Submission 0 20.04. Introduction to Operating Systems Course registration 1 27.04. Systems Programming using C (File Subsystem)
Tutorial on Socket Programming
Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Seyed Hossein Mortazavi (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian, ) 1 Outline Client- server
Using the CoreSight ITM for debug and testing in RTX applications
Using the CoreSight ITM for debug and testing in RTX applications Outline This document outlines a basic scheme for detecting runtime errors during development of an RTX application and an approach to
TFTP Usage and Design. Diskless Workstation Booting 1. TFTP Usage and Design (cont.) CSCE 515: Computer Network Programming ------ TFTP + Errors
CSCE 515: Computer Network Programming ------ TFTP + Errors Wenyuan Xu Department of Computer Science and Engineering University of South Carolina TFTP Usage and Design RFC 783, 1350 Transfer files between
Real Time Operating Systems. Tajana Simunic Rosing Department of Computer Science and Engineering University of California, San Diego.
Real Time Operating Systems Tajana Simunic Rosing Department of Computer Science and Engineering University of California, San Diego. 1 Software components Operating systems schedulers Middleware Standard
Using the NicheStack TCP/IP Stack - Nios II Edition Tutorial
Using the NicheStack TCP/IP Stack - Nios II Edition Tutorial Using the NicheStack TCP/IP Stack - Nios II Edition Tutorial 101 Innovation Drive San Jose, CA 95134 www.altera.com TU-01001-3.0 Subscribe Copyright
A Survey of Parallel Processing in Linux
A Survey of Parallel Processing in Linux Kojiro Akasaka Computer Science Department San Jose State University San Jose, CA 95192 408 924 1000 [email protected] ABSTRACT Any kernel with parallel processing
Project No. 2: Process Scheduling in Linux Submission due: April 28, 2014, 11:59pm
Project No. 2: Process Scheduling in Linux Submission due: April 28, 2014, 11:59pm PURPOSE Getting familiar with the Linux kernel source code. Understanding process scheduling and how different parameters
Networks and Protocols Course: 320301 International University Bremen Date: 2004-11-24 Dr. Jürgen Schönwälder Deadline: 2004-12-03.
Networks and Protocols Course: 320301 International University Bremen Date: 2004-11-24 Dr. Jürgen Schönwälder Deadline: 2004-12-03 Problem Sheet #10 Problem 10.1: finger rpc server and client implementation
Implementing Network Software
Implementing Network Software Outline Sockets Example Process Models Message Buffers Spring 2007 CSE 30264 1 Sockets Application Programming Interface (API) Socket interface socket : point where an application
Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No. # 26 Real - Time POSIX. (Contd.) Ok Good morning, so let us get
Linux for Embedded and Real-Time Systems
Linux for Embedded and Real-Time Systems Kaiserslautern 9 June 2005 Samir Amiry ([email protected]) Fraunhofer IESE Institut Experimentelles Software Engineering Outlines Introduction. Linux: the
Programming real-time systems with C/C++ and POSIX
Programming real-time systems with C/C++ and POSIX Michael González Harbour 1. Introduction The C language [1], developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories, is the most widely
LOW LEVEL FILE PROCESSING
LOW LEVEL FILE PROCESSING 1. Overview The learning objectives of this lab session are: To understand the functions provided for file processing by the lower level of the file management system, i.e. the
Concurrent Programming
Concurrent Programming Shared Memory Passing the baton Monitors Verónica Gaspes www.hh.se/staff/vero CERES, November 2, 2007 ceres Outline 1 Recap 2 Readers & Writers Readers & writers (mutual exclusion)
White Paper. Real-time Capabilities for Linux SGI REACT Real-Time for Linux
White Paper Real-time Capabilities for Linux SGI REACT Real-Time for Linux Abstract This white paper describes the real-time capabilities provided by SGI REACT Real-Time for Linux. software. REACT enables
Enhancing the Monitoring of Real-Time Performance in Linux
Master of Science Thesis Enhancing the Monitoring of Real-Time Performance in Linux Author: Nima Asadi [email protected] Supervisor: Mehrdad Saadatmand [email protected] Examiner: Mikael
Keil C51 Cross Compiler
Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation
Introduction to Socket Programming Part I : TCP Clients, Servers; Host information
Introduction to Socket Programming Part I : TCP Clients, Servers; Host information Keywords: sockets, client-server, network programming-socket functions, OSI layering, byte-ordering Outline: 1.) Introduction
REAL TIME OPERATING SYSTEMS. Lesson-10:
REAL TIME OPERATING SYSTEMS Lesson-10: Real Time Operating System 1 1. Real Time Operating System Definition 2 Real Time A real time is the time which continuously increments at regular intervals after
Linux 2.4. Linux. Windows
Linux 2.4 Non-preemptible kernel A system call might take long time to complete Coarse timer resolution Tasks can be released only with 10ms precision Virtual memory Introduces unpredictable amount of
Linux Kernel Rootkit : Virtual Terminal Key Logger
Linux Kernel Rootkit : Virtual Terminal Key Logger Jeena Kleenankandy Roll No. P140066CS Depatment of Computer Science and Engineering National Institute of Technology Calicut jeena [email protected]
Socket Programming in C/C++
September 24, 2004 Contact Info Mani Radhakrishnan Office 4224 SEL email mradhakr @ cs. uic. edu Office Hours Tuesday 1-4 PM Introduction Sockets are a protocol independent method of creating a connection
Implementing and testing tftp
CSE123 Spring 2013 Term Project Implementing and testing tftp Project Description Checkpoint: May 10, 2013 Due: May 29, 2013 For this project you will program a client/server network application in C on
Mouse Drivers. Alan Cox. [email protected]
Mouse Drivers Alan Cox [email protected] Mouse Drivers by Alan Cox Copyright 2000 by Alan Cox This documentation is free software; you can redistribute it and/or modify it under the terms of the GNU General
NS3 Lab 1 TCP/IP Network Programming in C
NS3 Lab 1 TCP/IP Network Programming in C Dr Colin Perkins School of Computing Science University of Glasgow http://csperkins.org/teaching/ns3/ 13/14 January 2015 Introduction The laboratory exercises
Win32 API Emulation on UNIX for Software DSM
Win32 API Emulation on UNIX for Software DSM Agenda: Sven M. Paas, Thomas Bemmerl, Karsten Scholtyssik, RWTH Aachen, Germany http://www.lfbs.rwth-aachen.de/ [email protected] Background Our approach:
Operating Systems. 12. Devices. Paul Krzyzanowski. Rutgers University. Spring 2015. 3/9/2015 2014-2015 Paul Krzyzanowski
Operating Systems 12. Devices Paul Krzyzanowski Rutgers University Spring 2015 3/9/2015 2014-2015 Paul Krzyzanowski 1 Devices Block devices: disk drives, flash memory Addressable blocks (suitable for caching)
IT304 Experiment 2 To understand the concept of IPC, Pipes, Signals, Multi-Threading and Multiprocessing in the context of networking.
Aim: IT304 Experiment 2 To understand the concept of IPC, Pipes, Signals, Multi-Threading and Multiprocessing in the context of networking. Other Objective of this lab session is to learn how to do socket
IPC. Semaphores were chosen for synchronisation (out of several options).
IPC Two processes will use shared memory to communicate and some mechanism for synchronise their actions. This is necessary because shared memory does not come with any synchronisation tools: if you can
Simple Cooperative Scheduler for Arduino ARM & AVR. Aka «SCoop»
Simple Cooperative Scheduler for Arduino ARM & AVR Aka «SCoop» Introduction Yet another library This library aims to provide a light and simple environment for creating powerful multi-threaded programs
Session NM059. TCP/IP Programming on VMS. Geoff Bryant Process Software
Session NM059 TCP/IP Programming on VMS Geoff Bryant Process Software Course Roadmap Slide 160 NM055 (11:00-12:00) Important Terms and Concepts TCP/IP and Client/Server Model Sockets and TLI Client/Server
Real-Time Operating Systems. http://soc.eurecom.fr/os/
Institut Mines-Telecom Ludovic Apvrille [email protected] Eurecom, office 470 http://soc.eurecom.fr/os/ Outline 2/66 Fall 2014 Institut Mines-Telecom Definitions What is an Embedded
Xillybus host application programming guide for Linux
Xillybus host application programming guide for Linux Xillybus Ltd. Version 2.0 1 Introduction 3 2 Synchronous vs. asynchronous streams 5 2.1 Overview................................... 5 2.2 Motivation
Chapter 6, The Operating System Machine Level
Chapter 6, The Operating System Machine Level 6.1 Virtual Memory 6.2 Virtual I/O Instructions 6.3 Virtual Instructions For Parallel Processing 6.4 Example Operating Systems 6.5 Summary Virtual Memory General
Multi-Threading Performance on Commodity Multi-Core Processors
Multi-Threading Performance on Commodity Multi-Core Processors Jie Chen and William Watson III Scientific Computing Group Jefferson Lab 12000 Jefferson Ave. Newport News, VA 23606 Organization Introduction
Programmation Systèmes Cours 9 UNIX Domain Sockets
Programmation Systèmes Cours 9 UNIX Domain Sockets Stefano Zacchiroli [email protected] Laboratoire PPS, Université Paris Diderot 2013 2014 URL http://upsilon.cc/zack/teaching/1314/progsyst/
Chapter 10 Case Study 1: LINUX
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 10 Case Study 1: LINUX History of UNIX and Linux UNICS PDP-11 UNIX Portable UNIX Berkeley UNIX Standard UNIX MINIX Linux UNIX/Linux Goals
CSC 2405: Computer Systems II
CSC 2405: Computer Systems II Spring 2013 (TR 8:30-9:45 in G86) Mirela Damian http://www.csc.villanova.edu/~mdamian/csc2405/ Introductions Mirela Damian Room 167A in the Mendel Science Building [email protected]
Data Types in the Kernel
,ch11.3440 Page 288 Thursday, January 20, 2005 9:25 AM CHAPTER 11 Data Types in the Kernel Chapter 11 Before we go on to more advanced topics, we need to stop for a quick note on portability issues. Modern
SMTP-32 Library. Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows. Version 5.2
SMTP-32 Library Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows Version 5.2 Copyright 1994-2003 by Distinct Corporation All rights reserved Table of Contents 1 Overview... 5 1.1
Comparison between scheduling algorithms in RTLinux and VxWorks
Comparison between scheduling algorithms in RTLinux and VxWorks Linköpings Universitet Linköping 2006-11-19 Daniel Forsberg ([email protected]) Magnus Nilsson ([email protected]) Abstract The
Operating Systems Concepts: Chapter 7: Scheduling Strategies
Operating Systems Concepts: Chapter 7: Scheduling Strategies Olav Beckmann Huxley 449 http://www.doc.ic.ac.uk/~ob3 Acknowledgements: There are lots. See end of Chapter 1. Home Page for the course: http://www.doc.ic.ac.uk/~ob3/teaching/operatingsystemsconcepts/
