tinycodinglm / sys /sys-0030.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 19)
034ba67 verified
|
Raw History Blame
1.86 kB
deepseek-harness trace
System You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing c...

You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies.

User

What are the Linux IPC mechanisms?

Assistant
markdown
1. Pipes (anonymous):
   pipe() -> read/write
   One-way, parent-child only

2. Named Pipes (FIFO):
   mkfifo /tmp/fifo 0666
   echo "data" > /tmp/fifo  # writer
   cat /tmp/fifo  # reader

3. Shared Memory:
   shmget() -> shmat() -> shmdt() -> shmctl()
   Fastest IPC, needs synchronization

4. Message Queues:
   msgget() -> msgsnd() -> msgrcv()
   Structured messages, priority

5. Semaphores:
   semget() -> semop()
   Synchronization primitive

6. Unix Domain Sockets:
   socket(AF_UNIX, SOCK_STREAM, 0)
   bind(), listen(), accept(), connect()
   Bidirectional, can pass file descriptors

7. D-Bus:
   High-level message bus
   Used by desktop environments
   gdbus call --session --dest org.freedesktop.DBus --object-path / --method org.freedesktop.DBus.ListNames

8. Signals:
   kill(pid, SIGTERM)
   signal(SIGINT, handler)
   Asynchronous notifications

Example (shared memory):
```c
int shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT | 0666);
void *ptr = shmat(shmid, NULL, 0);
strcpy(ptr, "Hello from parent");
// Child reads from same shmid
shmdt(ptr);
shmctl(shmid, IPC_RMID, NULL);
markdown