Code Monkey home page Code Monkey logo

spexamples's People

Stargazers

 avatar

spexamples's Issues

p75单线程版本和多线程版本写反了

p175单线程版本和多线程版本写反了:

正确的应该是:
单线程版本:
DList* dlist = dlist_create(NULL, NULL, NULL);


多线程版本:
DList* dlist = dlist_create(NULL, NULL, locker_pthread_create());


Original issue reported on code.google.com by [email protected] on 15 Apr 2010 at 9:57

dlist_delete

What steps will reproduce the problem?
1. 
执行并发一张中的第一个程序,会发现程序正常运行,断言��
�常
实质上是因为代码书写错误导致了程序的运行正常

What is the expected output? What do you see instead?
   在并发的测试链表的增加和删除时,删除节点的线程可能删除得更快,这样根本无
法得到RET_OK的结果,为什么断言正常是因为代码中dlist_delete��
�返回值被硬编码
为了RET_OK,按照意图,我认为这段代码的返回值应该是直接��
�回ret才对,也就是说
删除线程过快的删除,会返回 
INVALID_PARAM,这应该是个代码错误。

   如果想要真实的体现消费者和生产者,我觉得应该用条件变量cond。

What version of the product are you using? On what operating system?
cygwin, ubuntu

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 13 May 2010 at 3:01

P19中函数sum_cb的疑问

先静大哥,请问《系统程序员成长计划》第19页中函数sum_cb:
static DListRet sum_cb( void* ctx, void* data )
{
    long long* result = ctx;
    *result += ( int )data;

    return DLIST_RET_OK;
}

函数的第二行代码是不是应该为:*result += *( ( int* )data );

谢谢!

Original issue reported on code.google.com by [email protected] on 28 Dec 2010 at 8:05

deadlock occur in 4/2/locker directory.

What steps will reproduce the problem?
1. #cd 4/2/locker
2. #make
3. #./dlist_test

What is the expected output? What do you see instead?
The program should exit normal, but the program suspended.

What version of the product are you using? On what operating system?
I checked out in Dec, 16, 2011.

Please provide any additional information below.
Func dlist_insert 调用了 dlist_lock, func dlist_length调用了dlist_lock, 
but dlist_insert 又调用了dlist_length, then deadlock accured.

Thank you very much!

Original issue reported on code.google.com by [email protected] on 16 Dec 2011 at 2:20

Typo in page 231

231 
页第二段“分层设计是最古老的设计方法之一,也是最好有��
�的设计方法之一。”“最好有用”有语法错
误。疑似应为“最好用”或“最有用”。不过有一个理论是��
�指出别人的语法错误时自己必然范语法错误。所
以请先静老师原谅我这个 issue 里的语法错误 ;)

Original issue reported on code.google.com by [email protected] on 23 Apr 2010 at 12:12

free the memory safely!!

Chapter Darray

I use the MACRO SAFE_FREE(p) to free memory, but I want to test that 
wheather the memory was free safely or not. So when a darray was 
destroied, I still used darray_foreach() to print the darray. If you test 
it, you'll find that it still prints many integer numbers which are 
erratic. 

What is the expected output? What do you see instead?
I think when a darray is destroied, there are no numbers to print, because:
SAFE_FREE(thiz->data);
SAFE_FREE(thiz);
But in fact, many erratic numbers are printed.

Please provide any additional information below.
So I check the code. And fortunately, finally I found.
We use function free() to free memory safely
free() and malloc() must come in pairs.
The real memory area is thiz->data, so we free thiz->data and make the 
pointer thiz point to NULL. 
I think the above mentioned can avoid the problem.
Just like the following:

SAFE_FREE(thiz->data);
thix = NULL;

Original issue reported on code.google.com by [email protected] on 29 Apr 2010 at 6:54

动态数组内存管理的两个问题

What steps will reproduce the problem?
1.1.darray_set_by_index

2.1.get_by_index(thiz, 1, &pdata)
2.2.set_by_index(thiz, 2, pdata)
2.3.darray_destroy(thiz)

What is the expected output? What do you see instead?
1.直接set而不去free原有的元素,导致原有的元素所指向的内��
�不再有指针来标记,从而无法释放造成内存泄漏。

2.此条为疑问。这样操作会造成index 
1和2都指向同一块内存,在destroy的时候这块内存会被free两次�
��会不会出现什么问题?这个问题如果往下引申的话若数组中
有两个元素的指针指向同一块内存,其中一个元素被free之后�
��另一个指针的性质岂不是和野指针一样?这种情况下内存应
该如何管理呢?

What version of the product are you using? On what operating system?
Last Changed Rev: 5
Last Changed Date: 2010-04-21 21:37:48 +0800 (Wed, 21 Apr 2010)

ubuntu

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 28 Mar 2011 at 3:17

264 页状态机图问题

感觉那个“标识标签”里的“歌词”状态写错了。“ID标签”
状态表述更加准确。

Original issue reported on code.google.com by [email protected] on 23 Apr 2010 at 12:07

整数的比较函数实现好像有问题

int int_cmp(void* a, void* b)
{
    return (int)a - (int)b;
}
是把a和b的地址强转成int型后比较,并非比较a,b实际的值

应该是
int int_cmp(void* a, void* b)
{
    return *(int *)a - *(int *)b;
}

Original issue reported on code.google.com by [email protected] on 8 Aug 2010 at 4:31

读写锁代码错误

读写锁代码一章中,读写锁的unlock函数中,两个地方的读写��
�状态改变应该用赋值语
句不该用==

thiz->mode == RW_LOCKER_NONE;

这两个地方都用的是逻辑比较,应该是用赋值表示状态改变

thiz->mode = RW_LOCKER_NONE;

Original issue reported on code.google.com by [email protected] on 13 May 2010 at 6:57

the examples cannot compatible with 64-bit OS

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?
void* is 8 byte, while int is 4 byte in 64-bit system. some autotest maybe
have bug in this situation.

What version of the product are you using? On what operating system?
64-bit system

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 21 Apr 2010 at 1:36

线程安全链表问题请教

如果一个线程对链表有频繁的创建和删除操作, 
另外几个线程对链表有增加或者删除链表结点的操作. 
在这种情况下, 锁就不能放在链表内部了, 
所以请教在这种情况下的合理做法.

Original issue reported on code.google.com by [email protected] on 17 Jan 2012 at 1:51

动态数组章节中的冒泡排序

代码所示的算法并不是冒泡排序,是选择排序。是两种不同��
�算法
选择排序就是一轮先将最大的数选出,在适当位置做交换,��
�换的次数一共是n-1,如代
码中所示
冒泡排序时不断的在相邻两个位置做比较,在条件满足时不��
�的做交换

Original issue reported on code.google.com by [email protected] on 13 May 2010 at 9:10

p56页的比较函数?

int int_cmp(void *a, void *b) {
    return (int)a - (int)b; 
}
这样比较不是指针地址吗?可以这样做吗?还是一处错误?

谢谢

Original issue reported on code.google.com by [email protected] on 18 Aug 2011 at 8:13

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.